package dadarent;import java.util.Scanner;public class DadaRentSystem { public static void main(String[] args) { // TODO 自动生成的方法存根 System.out.println("欢迎使用答答租车系统:"); System.out.println("您是否要租车:1是 0否"); Scanner ipt = new Scanner (System.in); int yn = ipt.nextInt(); if (yn==0){ ipt.close(); return; } else{ System.out.println("您可租车的类型及其价目表:"); System.out.println("序号 汽车名称 租金 容量"); AudiA4 aud = new AudiA4(); Mazda6 maz = new Mazda6(); ChevroletPickup6 chv = new ChevroletPickup6(); Kinglong klg = new Kinglong(); HAMCSungari sgr = new HAMCSungari(); Iveco ivc = new Iveco(); System.out.println(aud.num()+". "+aud.type()+" "+aud.price()+"元/天 "+"载人:"+aud.PassengerCapacity()+"人"); System.out.println(maz.num()+". "+maz.type()+" "+maz.price()+"元/天 "+"载人:"+maz.PassengerCapacity()+"人"); System.out.println(chv.num()+". "+chv.type()+" "+chv.price()+"元/天 "+"载人:"+chv.PassengerCapacity()+"人 "+"载货:"+chv.CargoCapacity()+"吨"); System.out.println(klg.num()+". "+klg.type()+" "+klg.price()+"元/天 "+"载人:"+klg.PassengerCapacity()+"人"); System.out.println(sgr.num()+". "+sgr.type()+" "+sgr.price()+"元/天 "+"载货:"+sgr.CargoCapacity()+"吨"); System.out.println(ivc.num()+". "+ivc.type()+" "+ivc.price()+"元/天 "+"载货:"+ivc.CargoCapacity()+"吨"); System.out.println("请输入您要租汽车的数量:"); int n = ipt.nextInt(); String carriage = "" , lorry = ""; int passenger = 0 , vehicleNum = 0; double cargo = 0.0 , price = 0.0; for (int i = 1 ; i <= n ; i++ ){ System.out.println("请输入第"+i+"辆车的序号:"); vehicleNum = ipt.nextInt(); switch (vehicleNum){ case 1: carriage = carriage + " " + aud.type(); passenger = passenger + aud.PassengerCapacity(); price = price + aud.price(); break; case 2: carriage = carriage + " " + maz.type(); passenger = passenger + maz.PassengerCapacity(); price = price + maz.price(); break; case 3: carriage = carriage + " " + chv.type(); lorry = lorry + " " + chv.type(); passenger = passenger + chv.PassengerCapacity(); cargo = cargo + chv.CargoCapacity(); price = price + chv.price(); break; case 4: carriage = carriage + " " + klg.type(); passenger = passenger + klg.PassengerCapacity(); price = price + klg.price(); break; case 5: lorry = lorry + " " + sgr.type(); cargo = cargo + sgr.CargoCapacity(); price = price + sgr.price(); break; case 6: lorry = lorry + " " + ivc.type(); cargo = cargo + ivc.CargoCapacity(); price = price + ivc.price(); break; default: System.out.println("错误输入"); break; } } System.out.println("请输入租车天数:"); int day = ipt.nextInt(); price = price * day; ipt.close(); System.out.println("您的账单:"); System.out.println("***可载人的车有:"); System.out.println(carriage+" 共载人:"+passenger+"人"); System.out.println("***载货的车有:"); System.out.println(lorry+" 共载货:"+cargo+"吨"); System.out.println("租车总价格:"+price+"元"); } return; }}