附上代碼,歡迎討論指導(dǎo)!
public class UserController {
? ?public static void main (String[]args){
? ? ? ?System.out.println("HelloWorld!");
? ? ? ?System.out.println("歡迎使用達達租車系統(tǒng)");
? ? ? ?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("請輸入相應(yīng)序號");
? ? ? ?//選擇序號
? ? ? ?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("請輸入租車天數(shù)");
? ? ? ?//租車天數(shù)
? ? ? ?double ts = Double.parseDouble((scanner.next()));
? ? ? ?double hjzj = ?cars[xh].getCarDj()*ts;
? ? ? ?System.out.println("租車型號如上,租車天數(shù):"+ts+"天,合計租金:"+ hjzj+"元整。");
? ?}
? ?public static void pdzc(String sr){
? ? ? ?if("1".equals(sr)){
? ? ? ? ? ?System.out.println("歡迎進入達達租車系統(tǒng),以下為租車價目表。");
? ? ? ? ? ?return;
? ? ? ?}
? ? ? ?System.out.println("歡迎再次使用達達租車系統(tǒng)");
? ? ? ?//結(jié)束程序
? ? ? ?System.exit(0);
? ?}
2019-04-28
???newPK?new ZKnew ZR
2019-04-16
....