亂寫了一通好像能行哈哈哈哈
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 = "北京現(xiàn)代";
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("歡迎使用噠噠租車系統(tǒng):");
System.out.println("您是否需要租車:1.是? ? ? 0.否");
Scanner sc = new Scanner(System.in);
? ? ?int zc = sc.nextInt();
? ? ?if (zc==1){
? ? System.out.println("可租用車輛以及價(jià)格表:");
? ? System.out.println("序號(hào)\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("隨時(shí)歡迎您的使用~");
? ? ?}
? ? ?//獲取租車數(shù)量
? ? ?System.out.println("請(qǐng)輸入你要租賃的汽車數(shù)量:");
? ? ?Scanner sc1 = new Scanner(System.in);
? ? ?int count = sc1.nextInt();
? ? ?float sum = 0;
? ? ?//循環(huán)獲取具體的車輛信息
? ? ?if(count != 0){
? ? for(int i=1;i<=count;i++){
? ? System.out.print("請(qǐng)輸入第"+i+"輛車的序號(hào):");
? ? Scanner sc2 = new Scanner(System.in);
? ? ? ? ?int num = sc2.nextInt();
? ? ? ? ?//計(jì)算費(fèi)用
? ? 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("請(qǐng)輸入要租賃的天數(shù):");
? ? Scanner sc3 = new Scanner(System.in);
? ? ? ? ?int days = sc3.nextInt();
? ? ? ? ?sum = sum * days;
? ? ? ? ?
? ? ? ? ?System.out.println("您一共需要支付:"+sum+"元");
? ? ? ? ?System.out.println("期待您的下次使用~");
? ? ?}
}
}
2019-08-28
hahahhaha;
不知道為什么現(xiàn)在打字都要加分號(hào)了;
還有大括號(hào)亂入{
23333
}