第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

請(qǐng)問(wèn)還能精簡(jiǎn)嗎

car類:

package?com.CarRentSystem;

public?class?Vehicle?{

????String?name;
????int?carryPerson;
????int?carryFreight;
????int?price;

????public?Vehicle(String?name,int?carryPerson,int?carryFreight,int?price){
????????this.name?=?name;
????????this.carryPerson?=?carryPerson;
????????this.carryFreight?=?carryFreight;
????????this.price?=?price;
????}

????public?int?rent(int?days){
????????int?rent?=?days?*?this.price;
????????return?rent;
????}
}

主函數(shù):

package?com.CarRentSystem;

import?java.util.Scanner;


public?class?Initial?{

????public?static?void?main(String[]?args){

????????Vehicle[]?cars?=?{new?Vehicle("奧迪A6",4,0,500),
??????????????????????????new?Vehicle("馬自達(dá)6",4,0,400),
??????????????????????????new?Vehicle("皮卡雪6",4,2,450),
??????????????????????????new?Vehicle("金龍",20,0,800),
??????????????????????????new?Vehicle("松花江",0,4,400),
??????????????????????????new?Vehicle("依維柯",0,20,1000)};

????????Scanner?input?=?new?Scanner(System.in);
????????System.out.println("歡迎使用喵喵租車系統(tǒng)!");
????????System.out.println("請(qǐng)問(wèn)是否需要租車:1是,0否");
????????int?ifRent?=?Integer.parseInt(input.next());

????????if?(?ifRent?==?1){
????????????System.out.println("您可選擇的租車類型及價(jià)目表:");
????????????System.out.println("序號(hào)\t汽車名稱\t\t租金\t\t\t容量");
????????????for?(int?i?=?0?;i?<?6;i++){
????????????????System.out.print(i?+?1?+?"\t");
????????????????System.out.print(cars[i].name?+?"\t\t"?);
????????????????System.out.print(cars[i].price?+?"元/天\t\t");
????????????????if?(cars[i].carryPerson?==?0){
????????????????????System.out.println("載貨:"?+?cars[i].carryFreight?+?"噸");
????????????????}else?if?(cars[i].carryFreight?==?0){
????????????????????System.out.println("載人:"?+?cars[i].carryPerson?+?"人");
????????????????}else{
????????????????????System.out.println("載人:"?+?cars[i].carryPerson?+?"人,載貨:"?+?cars[i].carryFreight?+?"噸");
????????????????}
????????????}
????????}else{
????????????System.out.println("歡迎再次使用本系統(tǒng)!");
????????????return?;
????????}

????????System.out.println("請(qǐng)輸入需要租車的總天數(shù):");
????????int?days?=?Integer.parseInt(input.next());

????????System.out.println("請(qǐng)輸入需要租車的總數(shù)量:");
????????int?carCount?=?Integer.parseInt(input.next());

????????int?allCars[]?=?new?int[carCount];
????????for?(int?j?=?1;j?<?carCount?+?1;j++){
????????????System.out.println("選擇第"?+?j?+?"輛車的編號(hào):");
????????????allCars[j-1]?=?Integer.parseInt(input.next());
????????}

????????System.out.print("您選擇的車輛為:");

????????int?allPerson?=?0;
????????int?allFreight?=?0;
????????int?allPrice?=?0;

????????for?(int?m?=?0;?m?<?carCount;?m++){
????????????int?carCode?=?allCars[m];
????????????System.out.print(cars[carCode].name?+?"?");
????????????allPerson?+=?cars[carCode].carryPerson;
????????????allFreight?+=?cars[carCode].carryFreight;
????????????allPrice?+=?cars[carCode].rent(days);
????????}
????????System.out.println();
????????System.out.println("共可載人:"?+?allPerson?+?"人");
????????System.out.println("共可載貨:"?+?allFreight?+?"噸");
????????System.out.println("總價(jià)格為:"?+?allPrice?+?"元");
????}
}

輸出如下:

歡迎使用喵喵租車系統(tǒng)!

請(qǐng)問(wèn)是否需要租車:1是,0否

1

您可選擇的租車類型及價(jià)目表:

序號(hào) 汽車名稱 租金 容量

1 奧迪A6 500元/天 載人:4人

2 馬自達(dá)6 400元/天 載人:4人

3 皮卡雪6 450元/天 載人:4人,載貨:2噸

4 金龍 800元/天 載人:20人

5 松花江 400元/天 載貨:4噸

6 依維柯 1000元/天 載貨:20噸

請(qǐng)輸入需要租車的總天數(shù):

2

請(qǐng)輸入需要租車的總數(shù)量:

2

選擇第1輛車的編號(hào):

2

選擇第2輛車的編號(hào):

3

您選擇的車輛為:皮卡雪6 金龍?

共可載人:24人

共可載貨:2噸

總價(jià)格為:2500元


Process finished with exit code 0


正在回答

2 回答

你沒(méi)發(fā)現(xiàn)輸出結(jié)果與序號(hào)不匹配嗎?車輛序號(hào)都往后移了一位。

0 回復(fù) 有任何疑惑可以回復(fù)我~

從49行數(shù)組后面有點(diǎn)懵

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq__9440

把獲取到的值,存到數(shù)組里,然后循環(huán)遍歷數(shù)組下標(biāo)輸出值。之后循環(huán)累加每個(gè)數(shù)值。最后輸出結(jié)果
2019-08-06 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

請(qǐng)問(wèn)還能精簡(jiǎn)嗎

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)