麻煩看看接下來(lái)應(yīng)該咋做
System.out.println("歡迎使用達(dá)達(dá)租車系統(tǒng)");
? ? System.out.println("您是否要租車:是1 ? 否0");
? ? Scanner input = new Scanner (System.in);
? ? int i=input.nextInt();
? ? if (i==1){
? ? System.out.println("您可租車的類型及其價(jià)目表:");
? ? System.out.println("序號(hào)"+"\t"+"汽車名稱"+"\t"+"租金"+"\t"+"容量");
? ? }else{
? ? System.out.println("歡迎您再次光臨達(dá)達(dá)租車系統(tǒng)");
? ? }
? ? int j;
? ? for (j=0;j<6;j++){
? ? if (automobileMessenge[j] instanceof Car){
? ? System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"
? ? +automobileMessenge[j].rent+"元/天"+"\t"+"載人:"+((project7.Car) automobileMessenge[j]).getPeopleCount()+"人");
? ? }
? ? if (automobileMessenge[j] instanceof Trunk){
? ? System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"
? ? ? ? +automobileMessenge[j].rent+"元/天"+"\t"+"載貨:"+((project7.Trunk) automobileMessenge[j]).getThingCount()+"噸");
? ? }
? ? if (automobileMessenge[j] instanceof PickUp){
? ? System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"+
? ? automobileMessenge[j].rent+"元/天"+"\t"+"載人:"+((project7.PickUp) automobileMessenge[j]).getPeopleCount()
? ? ? ? +"載貨:"+((project7.PickUp) automobileMessenge[j]).getThingCount()+"噸");
? ? }
? ? }
? ? System.out.println("請(qǐng)輸入您要租車的數(shù)量");
? ? int carTotal=input.nextInt();
? ? int choice []=new int[carTotal];
? ? for(j=0;j<carTotal;j++){
? ? System.out.println("請(qǐng)輸入第"+""+(j+1)+"輛車的序號(hào)");
? ? choice [j]=input.nextInt();
? ? ? }
現(xiàn)在想把數(shù)組里的序號(hào)循環(huán)并判斷是能載人的還是能載貨的車并輸出出來(lái) ?實(shí)在沒(méi)有思路
2017-04-15
package 租車系統(tǒng);
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
// TODO 自動(dòng)生成的方法存根
Carriage c1=new Carriage("奧迪A4",500,4);
Carriage c2=new Carriage("馬自達(dá)6",400,4);
Carriage c3=new Carriage("金龍",800,20);
PK p1=new PK("皮卡雪6",450,4,2);
Truck t1=new Truck("松花江",400,4);
Truck t2=new Truck("依維柯",1000,20);
System.out.println("歡迎使用租車系統(tǒng)");
System.out.println("是否租車 0否-1是");
//選擇是否租車
Scanner s1=new Scanner(System.in);
double x1=s1.nextDouble();
if(x1==1)
{
//輸出租車信息
System.out.println("當(dāng)前可租類型及其價(jià)目表");
System.out.println("序號(hào) ? ?汽車名稱 ? ?租金 ? ? ?容量");
System.out.print("1. ? ");
c1.Introduce();
System.out.print("2. ? ");
c2.Introduce();
System.out.print("3. ? ");
p1.Introduce();
System.out.print("4. ? ");
t1.Introduce();
System.out.print("5. ? ");
t2.Introduce();
//租車數(shù)量
System.out.println("請(qǐng)輸入您要租的數(shù)量");
Scanner s2=new Scanner(System.in);
int x2=s2.nextInt();
//租的車 天數(shù)總和 ?金錢總和....
int SumDay=0;
int SumManey=0;
int SumVolume=0; //總載人
int SumVolume1=0;//總載貨
String st1="";
String st2="";
String st3="";
String st4="";
String st5="";
for(int i=1;i<=x2;i++){
System.out.println("請(qǐng)輸入第"+i+"輛車的序號(hào):");
Scanner s3=new Scanner(System.in);
int x=s3.nextInt();
switch (x)
{
case 1: ?SumManey+=c1.maney;SumVolume+=c1.volume;st1=c1.name;break;
case 2: ?SumManey+=c2.maney;SumVolume+=c2.volume;st2=c2.name;break;
case 3: ?SumManey+=p1.maney;SumVolume+=p1.volume;SumVolume1+=p1.volume1;st3=p1.name;break;
case 4: ?SumManey+=t1.maney;SumVolume1+=t1.volume;st4=t1.name;break;
case 5: ?SumManey+=t2.maney;SumVolume1+=t2.volume;st5=t2.name;break;
default: System.out.println("輸入有誤");break;
}//switch語(yǔ)句里
}//for循環(huán)里
System.out.println("請(qǐng)輸入租車天數(shù)");
Scanner s4=new Scanner(System.in);
int day=s4.nextInt();
System.out.println("賬單詳情:");
System.out.println("可載人的有:"+st1+" ?"+st2+" ?"+st3+" ?共"+SumVolume+"人");
System.out.println("可載貨的有: "+st3+" ?"+st4+" ?"+st5+" ?共"+SumVolume1+"噸");
SumManey*=day;
System.out.println("總租金為"+SumManey);
}
}
}