题目的理解
如果输入的车的序号有相同的,或者要的车多于6辆怎么办
import java.util.*;
public class UI {
public static void main(String[] args){
System.out.println("欢迎来到达达租车系统");
Scanner input=new Scanner(System.in);
System.out.println("您是否需要租车:"+"\n"+"1,是;2.否");
int a=input.nextInt();
if(a==1){
System.out.println("您可租车的类型及价目表:"+"\n"+"序号 汽车名称 租金 容量 "+"\n"+"1 奥迪A4 500元/天 载人4人"+"\n"+"2 马自达6 400元/天 载人4人");
System.out.println("3 皮卡雪6 450元/天 载人4载货2吨"+"\n"+"4 金龙 800元/天 载人20人"+"\n"+"5 松花江 400元/天 载货4吨"+"\n"+"6 依维柯 1000元/天 载货20吨");
System.out.println("请输入您要租车的数量:");
Scanner Nums=new Scanner(System.in);
int b=input.nextInt(); //***b是总共租车的数量
//System.out.println("请输入您要租车的数量:");
int[] type=new int[6];/////////
int j=0;//输入车数组的下标
for(int i=1;i<=b;i++){
System.out.println("请输入第"+i+"辆车的序号"); //***判断每辆车的序号
Scanner order=new Scanner(System.in);
int c=input.nextInt(); //***c是车的种类序号
type[j]=c;
j++;
int f=type[1]; //这段是有异常的,如果大于6辆车就是无法判断的,或者两辆一样的车,后面的输出可能会输出多次车类型
}//***for的括号
//System.out.println(Arrays.toString(type));
System.out.println("请输入租车的天数");
Scanner days=new Scanner(System.in);
int d=input.nextInt();
System.out.println("您的账单:"); //***输出账单
System.out.println("***可载人的车有:");
vehicle car1=new AoDi();
vehicle car2=new MaZiDa();
vehicle car3=new PiKa();
vehicle car4=new JinLong();
vehicle car5=new SongHuaJiang();
vehicle car6=new YiWeiKe();
//System.out.println(Arrays.toString(type));
for(int h=0;h<=j;h++){
if (type[h]==1){
car1.run();
}
if(type[h]==2){
car2.run();
}
if(type[h]==3){
car3.run();
}
if(type[h]==4){
car4.run();
}
}
System.out.println("\n");
System.out.println("****可以装货的车有");
//System.out.println(Arrays.toString(type));
for(int f=0;f<=j;f++){
if (type[f]==3){
car3.run();
}
if(type[f]==5){
car5.run();
}
if(type[f]==6){
car6.run();
}
}
}
if(a==0){
System.out.println("谢谢使用");
}
}
}