亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

搞了一個下午才寫出這些,求大神指點

import java.util.Scanner;


?class Automobile {

private String name;//汽車名字

private int rent;//汽車日租金

private int busload;//汽車載客量

private int boatload;//汽車載貨量

//租車車輛屬性

public void nature(int num, String name, int rent, int busload, int boatload) {

this.name = name;

this.rent = rent;

this.busload = busload;

this.boatload = boatload;

System.out.println("序號:" + num + "\t汽車名:" + name + "\t 日租金:" + rent + "元" + "\t 可載客量:" + busload + "人"

+ "\t 可載貨量:" + boatload + "噸");

}


//計算賬單

public static void rental(int days, int rent, int num) {

int rental = days * rent * num;

System.out.println("***您的賬單***");

System.out.println("租用天數:" + days + "\t租用數量:" + num + "\t 總金額:" + rental + "元");

}


//輸入租車信息

public static void dowork(int rent) {

Scanner input = new Scanner(System.in);

System.out.println("請輸入您要租用的天數!");

int c = input.nextInt();

System.out.println("請輸入您要租用的車輛的數量!");

int d = input.nextInt();

rental(c, rent, d);

}


}




public class RentCat {

public static void main(String[] args) {

Automobile audiA4 = new Automobile();//創建奧迪A4對象

Automobile azda6 = new Automobile();//創建馬自達6對象

Automobile pick_up = new Automobile();//創建皮卡雪6對象

Automobile jinlong = new Automobile();//創建金龍對象

Automobile songhua = new Automobile();//創建松花江對象

Automobile iveco = new Automobile();//創建依維柯對象


System.out.println("歡迎來到噠噠租車系統!!");

System.out.println("您是否要租車,是按1,否按0");

Scanner input = new Scanner(System.in);

int a = input.nextInt();

if (a == 1) {

//租車價目表

System.out.println("您可租車的類型和價目表:");

audiA4.nature(1, "奧迪A4", 500, 4, 0);

azda6.nature(2, "馬自達6", 400, 4, 0);

pick_up.nature(3, "皮卡雪6", 450, 4, 2);

jinlong.nature(4, "金龍 ? ", 800, 20, 0);

songhua.nature(5, "松花江", 400, 0, 4);

iveco.nature(6, "依維柯", 1000, 0, 20);

} else {

System.out.println("請關閉系統!!");


}

System.out.println("請輸入您要租用的汽車序號:");

int b = input.nextInt();

if (b == 1) {

audiA4.nature(1, "奧迪A4", 500, 4, 0);

Automobile.dowork(500);

} else if (b == 2) {

azda6.nature(2, "馬自達6", 400, 4, 0);

Automobile.dowork(400);

} else if (b == 3) {

pick_up.nature(3, "皮卡雪6", 450, 4, 2);

Automobile.dowork(450);

} else if (b == 4) {

jinlong.nature(4, "金龍 ? ? ? ", 800, 20, 0);

Automobile.dowork(800);

} else if (b == 5) {

songhua.nature(5, "松花江", 400, 0, 4);

Automobile.dowork(400);

} else if (b == 6) {

iveco.nature(6, "依維柯", 1000, 0, 20);

Automobile.dowork(1000);

} else {

System.out.println("您的輸入有誤!!");

}


}

}


正在回答

2 回答

可以選擇交互式對話框輸入。個人建議

0 回復 有任何疑惑可以回復我~

http://img1.sycdn.imooc.com//598acb290001193206250427.jpg

輸出結果


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

搞了一個下午才寫出這些,求大神指點

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號