交作業(yè)了,菜鳥一個(gè),別噴
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
? ?System.out.println("歡迎來到達(dá)達(dá)租車系統(tǒng)~");
? ? ?System.out.println("您是否要租車?1.是。0.否。");
? ? ?Scanner sc = new Scanner(System.in);
? ? ?int a = sc.nextInt();
? ? ?if(a == 1){
? ? ?Dada d = new Dada();
? ? ?d.show();
? ? ?Da dd = new Da();
? ? ?dd.show();
? ? ?System.out.println("祝您使用愉快!");
? ? ?}else if(a == 0){
? ? ?System.out.println("已退出達(dá)達(dá)租車系統(tǒng),歡迎下次光臨!");
? ? ?}
? ? ?else{
? ? ?System.out.println("老鐵,別搞事情!");?
? ? ? ?System.out.println("請(qǐng)輸入1.是或者0.否。");
? ? ? ? ?int b = sc.nextInt();
? ? ? ?if(b == 1){
? ? ? ? ?Dada ddd = new Dada();
? ? ? ? ?ddd.show();
? ? ? ? ?Da dddd = new Da();
? ? ? ? ?dddd.show();
? ? ? ? ?System.out.println("祝您使用愉快!");
? ? ? ? ?}else if(b == 0){
? ? ? ? ?System.out.println("已退出達(dá)達(dá)租車系統(tǒng),歡迎下次光臨!");
? ? ? ? ?}
? ? ? ? ?else{
? ? ? ? ?System.out.println("拜拜了您嘞");
? ? ? ? ?}
? ? ?}
}
}
public class Dada {
? ? ? ?public void show(){
? ? ? System.out.println("您可租的車輛以及價(jià)格信息表");
? ? String[][]str = {{"序號(hào)? ? ? ?車輛? ? ? ? ? ?租金? ? ? ? ? ? ? ? 容 量"},{"1? ? 奧迪? ? ? ?500元/天? ? ? ?4人"},{"2? ? 大寶馬? ? 500元/天? ? ? 10人? "},
? ? { "3? ? 金龍? ? ? ?400元/天? ? ? 載貨2噸"},{"4? ? 皮卡雪? ? ? ?600元/天? ? ? 載貨4噸"}};
? ? for(int i = 0;i < str.length; i++){
? ? for(int j = 0;j < str[i].length; j++){
? ? System.out.println(str[i][j]);
? ? }
? ? }
? ? ? ?}
}
import java.util.Scanner;
public class Da extends Dada {
public Da(){
System.out.println("請(qǐng)輸入您要租汽車的數(shù)量:");
}
? ? ? public void show(){
? ? ? Scanner sc = new Scanner(System.in);
? ? ? int x = sc.nextInt();
? ? ? int sum = 0;
? ? ? for(int i = 1;i <= x; i++){
? ? ? System.out.println("請(qǐng)輸入第"+i+"輛汽車序號(hào):");
? ? ? ? ? int y = sc.nextInt();
? ? ? ? ? String[][]str = {{"序號(hào)? ? ? ?車輛? ? ? ? ? ?租金? ? ? ? ? ? ? ? 容 量"},{"1? ? 奧迪? ? ? ?500元/天? ? ? ?4人"},{"2? ? 大寶馬? ? 500元/天? ? ? 10人? "},
? ? ? ? ? { "3? ? 金龍? ? ? ?400元/天? ? ? 載貨2噸"},{"4? ? 皮卡雪? ? ? ?600元/天? ? ? 載貨4噸"}};
? ? ? ? ? if(y == 1){
? ? ? ? ? System.out.println("您點(diǎn)了"+str[y][0]);
? ? ? ? ? }
? ? ? ? ? if(y == 2){
? ? ? ? ? System.out.println("您點(diǎn)了"+str[y][0]);
? ? ? ? ? }
? ? ? ? ? if(y == 3){
? ? ? ? ? System.out.println("您點(diǎn)了"+str[y][0]);
? ? ? ? ? }
? ? ? ? ? if(y == 4){
? ? ? ? ? System.out.println("您點(diǎn)了"+str[y][0]);
? ? ? ? ? }
? ? ? ? ? switch(y){
? ? ? ? ? ? ?case 1: sum += 500;break;
? ? ? ? ? ? ?case 2: sum += 500;break;
? ? ? ? ? ? ?case 3: sum += 400;break;
? ? ? ? ? ? ?case 4: sum += 300;break;
? ? ? ? ? }
? ? ? }
? ? System.out.println("請(qǐng)輸入租車天數(shù):");
? ? int z = sc.nextInt();
? ? sum = sum * z;
? ? System.out.println("總價(jià)格:"+sum);
? ? ? }
}
2020-07-30
可以,加油,但可別在真的項(xiàng)目里面輸出一些搞怪句子喲