package com.dadarentcarsys;
import java.util.Scanner;
public class mainProject {
@SuppressWarnings({ "unused", "resource" })
public static void main(String[] args) {
// TODO Auto-generated method stub
Car2 car1=new Car2("奥迪A4 ",500,4);
Car2 car2=new Car2("马自达6 ",400,4);
Car3 car3=new Car3("皮卡雪 ",450,2,4);
Car2 car4=new Car2("金龙 ",800,20);
Car1 car5=new Car1("松花江 ",400,2);
Car1 car6=new Car1("依维柯 ",1000,20);
System.out.println("欢迎使用答答租车系统:");
Scanner input =new Scanner(System.in);
int i;
do{
System.out.println("您是否要租车:1是,0否");
i=input.nextInt();
if(i==1){
System.out.println("您可租车的类型及其价目表:");
System.out.println("序号\t汽车名称\t租金\t 容量");
System.out.println("1.\t"+car1.name+"\t"+car1.money+"元/天 "+"载人:"+car1.human+"人");
System.out.println("2.\t"+car2.name+"\t"+car2.money+"元/天 "+"载人:"+car2.human+"人");
System.out.println("3.\t"+car3.name+"\t"+car3.money+"元/天 "+"载人:"+car3.human+"人 "+"载重:"+car3.height+"吨");
System.out.println("4.\t"+car4.name+"\t"+car4.money+"元/天 "+"载人:"+car4.human+"人");
System.out.println("5.\t"+car5.name+"\t"+car5.money+"元/天 "+"载重:"+car5.height+"吨");
System.out.println("6.\t"+car6.name+"\t"+car6.money+"元/天 "+"载重:"+car6.height+"吨");
String name1[]=new String[10];
String name2[]=new String[10];
int [] days=new int[10];
int [] money1=new int[10];
int human1=0;
int height1=0;
int j;
int sum=0;
int k=0;
do{
System.out.println("请输入要租车的车类序号:");
int quantity=input.nextInt();//租车的数量
System.out.println("请输入所租车的天数:");
days[k]=input.nextInt();//租车的天数
switch(quantity){
case 1:
name1[k]=car1.name;
money1[k] = car1.money;
human1 += car1.human;
break;
case 2:
name1[k]=car2.name;
money1[k]=car2.money;
human1+=car2.human;
break;
case 3:
name1[k]=car3.name;
money1[k]=car3.money;
human1+=car3.human;
height1+=car3.height;
break;
case 4:
name1[k]=car4.name;
money1[k]=car4.money;
human1+=car4.human;
break;
case 5:
name1[k]=car5.name;
money1[k]=car5.money;
height1+=car5.height;
break;
case 6:
name1[k]=car6.name;
money1[k]=car6.money;
height1+=car6.height;
break;
}
k++;
System.out.println("请问是否还继续租车:1是,0否");
j=input.nextInt();
while(j>1){
System.out.println("输入有误,请重新输入");
System.out.println("请问是否还继续租车:1是,0否");
j=input.nextInt();
}
if(j==0){
System.out.println("您的账单:");
for(int count=1;count<name1.length&&days[count-1]!=0;count++){
System.out.println(count+".\t"+name1[count-1]+"\t"+days[count-1]+"天 "+"\t价格:"+money1[count-1]*days[count-1]+"元");
sum+=money1[count-1]*days[count-1];
}
System.out.println("应付总价格为:"+sum+"元");
}
}while(j==1);
}
else if(i>1){
System.out.println("输入有误,请重新输入");
}
else {
System.out.println("欢迎您再来!");
}
}while(i>1);
}
}
点击查看更多内容
15人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦