6-1項(xiàng)目問(wèn)題,為什么最后可載人,可載貨沒(méi)有輸出
package zuche;
import java.util.Scanner;
public class Text {
public static int money=0;
public static int person=0;
public static int burden=0;
public static String[] r;
public static String[] h;
public static int j=0;
public static int k=0;
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
? ? ? ? ? ?ab ab=new ab();
? ? ? ? System.out.println("是否進(jìn)入租車系統(tǒng) 1:是;0:否");
? ? ? ? ? ?int x=scan.nextInt();
? ? ? ? ? ?if(ab.ab(x)==1){
Car[] car={new a(),new b(),new c(),new d(),new e(),new f()};
System.out.println("輸入你租車的數(shù)量");
int num=scan.nextInt();
System.out.println("輸入你要租用的天數(shù)");
int day=scan.nextInt();
for(int i=0;i<num;i++){
System.out.print("輸入你第"+(i+1)+"輛所選的車");
String ch=scan.next();
if(ch=="a"){
r[j]="奧迪A4";
j++;
}
if(ch=="b"){
r[j]="馬自達(dá)6";
j++;
}
if(ch=="c"){
r[j]="皮卡雪6";
? ? ? ? h[k]="皮卡雪6";
j++;
k++;
}
if(ch=="d"){
r[j]="金龍";
j++;
}
if(ch=="e"){
h[k]="松花江";
k++;
}
if(ch=="f"){
h[k]="依維柯";
k++;
}
switch (ch){
case "a":money=money+500*day;
? ? ? ? person+=4;
? ? ? ? break;
case "b":money=money+400*day;
? ? person+=4;
? ? break;
case "c":money=money+450*day;
? ? person+=4;
? ? burden+=2;
? ? break;
case "d":money=money+800*day;
? ? person+=20;
? ? break;
case "e":money=money+400*day;
? ? burden+=4;
? ? break;
case "f":money=money+1000*day;
? ? burden+=20;
? ? break;
}
}
System.out.println("可載人的車有");
for(int j1=0;j1<j;j1++){
System.out.println(r[j1]);
}
System.out.println("可載貨的車有");
for(int k1=0;k1<k;k1++){
System.out.println("h[k1]");
}
System.out.println("總載人"+person+"總載貨"+burden);
System.out.println("總價(jià)格為"+money);
}
scan.close();
}
}
2017-02-06
代碼沒(méi)有格式化,不好看,把項(xiàng)目打包發(fā)給我吧,我抽空幫你看看,1808570357@qq.com