乱写了一通好像能行哈哈哈哈
package com.imooc;
import java.util.Scanner;
public class Initail {
/**
* @param args
*/
public static void main(String[] args) {
Pickup p = new Pickup();
p.name = "皮卡";
p.busload = 4;
p.cargo = 3;
p.type = "pickup";
p.rent = 200;
Bus b = new Bus();
b.name = "南通客车";
b.busload = 20;
b.cargo = 0;
b.type = "Bus";
b.rent = 300;
Bus b1 = new Bus();
b1.name = "北京现代";
b1.busload = 6;
b1.cargo = 0;
b1.type = "limousine";
b1.rent = 250;
Trucks t = new Trucks();
t.name = "大卡车";
t.busload = 2;
t.cargo = 30;
t.type = "Trucks";
t.rent = 400;
Trucks t1 = new Trucks();
t1.name = "小货车";
t1.busload = 2;
t1.cargo = 10;
t1.type = "buggy";
t1.rent = 350;
System.out.println("欢迎使用哒哒租车系统:");
System.out.println("您是否需要租车:1.是 0.否");
Scanner sc = new Scanner(System.in);
int zc = sc.nextInt();
if (zc==1){
System.out.println("可租用车辆以及价格表:");
System.out.println("序号\t 汽车名称\t 租金\t\t 容量");
System.out.println("1\t "+b1.name+"\t" +b1.rent+"元/天\t 载客量:"+b1.busload+"人/辆\t载货量:"+b1.cargo+"吨/辆");
System.out.println("2\t "+b.name+"\t" +b.rent+"元/天\t 载客量:"+b.busload+ "人/辆\t载货量:"+b.cargo+"吨/辆");
System.out.println("3\t "+p.name+"\t" +p.rent+"元/天\t 载客量:"+p.busload+ "人/辆\t载货量:"+p.cargo+"吨/辆");
System.out.println("4\t "+t.name+"\t" +t.rent+"元/天\t 载客量:"+t.busload+ "人/辆\t载货量:"+t.cargo+"吨/辆");
System.out.println("5\t "+t1.name+"\t" +t1.rent+"元/天\t 载客量:"+t1.busload+ "人/辆\t载货量:"+t1.cargo+"吨/辆");
}
else{
System.out.println("随时欢迎您的使用~");
}
//获取租车数量
System.out.println("请输入你要租赁的汽车数量:");
Scanner sc1 = new Scanner(System.in);
int count = sc1.nextInt();
float sum = 0;
//循环获取具体的车辆信息
if(count != 0){
for(int i=1;i<=count;i++){
System.out.print("请输入第"+i+"辆车的序号:");
Scanner sc2 = new Scanner(System.in);
int num = sc2.nextInt();
//计算费用
switch(num){
case 1:
sum+=b1.rent;
break;
case 2:
sum+=b.rent;
break;
case 3:
sum+=p.rent;
break;
case 4:
sum+=t.rent;
break;
case 5:
sum+=t1.rent;
}
}
System.out.println("请输入要租赁的天数:");
Scanner sc3 = new Scanner(System.in);
int days = sc3.nextInt();
sum = sum * days;
System.out.println("您一共需要支付:"+sum+"元");
System.out.println("期待您的下次使用~");
}
}
}