神无月Y
2019-04-10 16:20
public class UserController {
public static void main (String[]args){
System.out.println("HelloWorld!");
System.out.println("欢迎使用达达租车系统");
System.out.println("确定租车请输入1,退出输入0");
Scanner scanner = new Scanner(System.in);
String sr = scanner.next();
//判断是否租车
pdzc(sr);
Car [] cars ={
new PK("皮卡",100,1,"皮卡型"),
new ZK("大巴车",200,5,"载客型"),
new ZR("大货车",300,6,"载货型")};
int i =1;
for (Car as:cars) {
System.out.println("序号:"+ i++ +",车辆型号:"+as.getTx()+",车辆名称:"+as.getCarName()+",车辆动力:"+as.getPl()+",车辆日租金:"+as.getCarDj());
}
System.out.println("请输入相应序号");
//选择序号
int xh1 = Integer.parseInt(scanner.next());
int xh = xh1-1;
System.out.println("序号:"+ xh1 +",车辆型号:"+cars[xh].getTx()+",车辆名称:"+cars[xh].getCarName()+",车辆动力:"+cars[xh].getPl()+",车辆日租金:"+cars[xh].getCarDj());
System.out.println("请输入租车天数");
//租车天数
double ts = Double.parseDouble((scanner.next()));
double hjzj = cars[xh].getCarDj()*ts;
System.out.println("租车型号如上,租车天数:"+ts+"天,合计租金:"+ hjzj+"元整。");
}
public static void pdzc(String sr){
if("1".equals(sr)){
System.out.println("欢迎进入达达租车系统,以下为租车价目表。");
return;
}
System.out.println("欢迎再次使用达达租车系统");
//结束程序
System.exit(0);
}
???newPK new ZKnew ZR
....
Java入门第二季 升级版
530652 学习 · 6091 问题
相似问题