package rent;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Car[] carforrent=new Car[]{new Bus("奥迪A4",500,0,4),new Bus("马自达6",400,0,4),new Pickup("皮卡雪6",450,2,4),
new Bus("金龙",800,0,20),new Truck("松花江",400,4,0),new Truck("依维柯",1000,20,0)};
System.out.println("欢迎使用答答租车系统:");
System.out.println("您是否要租车:1是 0否");
Scanner input=new Scanner(System.in);
int choice=input.nextInt();
if(choice==1){
System.out.println("您可租车的类型以及价目表:");
System.out.println("序号\t汽车名称\t租金\t\t容量");
for(int i=0;i<carforrent.length;i++){
System.out.print((i+1)+"\t"+carforrent[i].getName()+"\t"+carforrent[i].getRent()+"元/天\t");
if(carforrent[i].getBusload()!=0)
System.out.print("载人:"+carforrent[i].getBusload()+"人 ");
if(carforrent[i].getBurden()!=0)
System.out.print("载货:"+carforrent[i].getBurden()+"吨");
System.out.println();
}
System.out.println("请输入您要租用汽车的数量:");
Scanner input1=new Scanner(System.in);
int num=input1.nextInt();
int [] carID=new int[num];
for(int i=0;i<num;i++){
int j=i+1;
System.out.println("请输入第"+j+"辆车的序号:");
Scanner input2=new Scanner(System.in);
carID[i]=input2.nextInt();
}
System.out.println("请输入租车天数:");
Scanner input3=new Scanner(System.in);
int days=input3.nextInt();
System.out.println("您的账单:");
int sumofbusload=0;
int sumofburden=0;
double rents=0;
System.out.println("***可载人的车有:");
for(int i=0;i<num;i++){
if(carID[i]==1){
System.out.print(carforrent[0].getName()+" ");
sumofbusload+=carforrent[0].getBusload();
rents+=carforrent[0].getRent();
}
else if(carID[i]==2){
System.out.print(carforrent[1].getName()+" ");
sumofbusload+=carforrent[1].getBusload();
rents+=carforrent[1].getRent();
}
else if(carID[i]==3){
System.out.print(carforrent[2].getName()+" ");
sumofbusload+=carforrent[2].getBusload();
rents+=carforrent[2].getRent();
}
else if(carID[i]==4){
System.out.print(carforrent[3].getName()+" ");
sumofbusload+=carforrent[3].getBusload();
rents+=carforrent[3].getRent();
}
else continue;
}
System.out.println("共载人:"+sumofbusload+"人");
System.out.println("***可载货的车有:");
for(int i=0;i<num;i++){
if(carID[i]==3){
System.out.print(carforrent[2].getName()+" ");
sumofburden+=carforrent[2].getBurden();
}
else if(carID[i]==5){
System.out.print(carforrent[4].getName()+" ");
sumofburden+=carforrent[4].getBurden();
rents+=carforrent[4].getRent();
}
else if(carID[i]==6){
System.out.print(carforrent[5].getName()+" ");
sumofburden+=carforrent[5].getBurden();
rents+=carforrent[5].getRent();
}
else continue;
}
System.out.println("共载货:"+sumofburden+"吨");
System.out.println("***租车总价格:"+rents*days);
}
else
System.out.println("正退出答答租车系统");
怪盗饭团
相关分类