qq_咦我的杯杯呢_0
2017-06-23 10:31:13浏览 2586
package dada;
import java.util.Scanner;
public class dada {
public static void main (String[] args){
System.out.println("欢迎使用答答租车系统");
System.out.println("您是否要租车:1是 2否");
Scanner inp = new Scanner(System.in);
int num =inp.nextInt();
switch (num){ //用switch判断,1进入程序 其他则退出
case 1:
System.out.println("您可租车的类型及价目表:");
System.out.println("序号-汽车名称-租金----容量");
int pic1 = 500;//序号1车的价钱
int pre1 = 4;//序号1车的载人数
System.out.println("1.--奥迪A4--"+pic1+"元/天-"+pre1+"人");
int pic2 = 400;
int pre2 = 4;
System.out.println("2.--马自达6-"+pic2+"元/天-"+pre2+"人");
int pic3 = 450;
int pre3 = 4;
int load3 =2;//序号3车的载重数
System.out.println("3.--皮卡---"+pic3+"元/天--"+pre3+"人"+load3+"吨");
int pic4 = 800;
int pre4 = 20;
System.out.println("4.--金龙---"+pic4+"元/天--"+pre4+"人");
int pic5 = 400;
int load5 = 4;
System.out.println("5.--松花江--"+pic5+"元/天--"+load5+"吨");
int pic6 = 1000;
int load6 = 20;
System.out.println("6.--依维柯--"+pic6+"元/天--"+load6+"吨");
System.out.println("请输入您要租车的数量:");
Scanner inpu = new Scanner(System.in);
int num2 = inpu.nextInt();
int sumPic=0;//租车总价
int sunPre=0;//租车总载人数
int sunLoad=0;//租车总载重数
//下面循坏为选择车辆序号,并且每选择一次累加一次总价、总载人、、总载重
for (int i = 1;i<=num2;i++){
System.out.println("请输入第"+i+"辆车的序号:");
int num3= inp.nextInt();
switch(num3){
case 1:
sumPic=sumPic+pic1;
sunPre=sunPre+pre1;
break;
case 2:
sumPic=sumPic+pic2;
sunPre=sunPre+pre2;
break;
case 3:
sumPic=sumPic+pic3;
sunPre=sunPre+pre3;
sunLoad = sunLoad+load3;
break;
case 4:
sumPic=sumPic+pic4;
sunPre=sunPre+pre4;
break;
case 5:
sumPic=sumPic+pic5;
sunLoad=sunLoad+load5;
break;
case 6:
sumPic=sumPic+pic6;
sunLoad=sunLoad+load6;
break;
}
}
System.out.println("请输入租车天数:");
int f = inp.nextInt();
int zongjia =f*sumPic;
System.out.println("你租车的总价格为:"+zongjia+"元");
System.out.println("你总人数为:"+sunPre+"人");
System.out.println("你总载重为:"+sunLoad+"吨");
break;
default:
System.out.println("谢谢使用,再见!");
break;
}
}
}
热门评论
全是硬代码啊,用面向对象写一下吧...