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

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

看了別人的自己才有點思路,我的應該是最簡單易懂的了,就是感覺沒用上第二季的知識


package com.dadazuche;


public class CarStore {

private String name;

private int jine;

private int zairenliang;

private int zaihuoliang;

public CarStore(String name,int jine,int zairenliang,int zaihuoliang) {

this.name=name;

this.jine=jine;

this.zairenliang=zairenliang;

this.zaihuoliang=zaihuoliang;

}

public String getname() {

return name;

}


public int getjine() {

return jine;

}


public int getzairenliang() {

return zairenliang;

}


public int getzaihuoliang() {

return zaihuoliang;

}


}

package com.dadazuche;

import java.util.*;

public class test {


public static void main(String[] args) {

// TODO Auto-generated method stub

int sum=0;

int zzhl=0;

int zzkl=0;

CarStore[] CarList= {

new CarStore("奧迪",2000,5,0),

new CarStore("寶馬",2500,5,0),

new CarStore("五菱宏光",800,12,0),

new CarStore("法拉利",8000,2,0),

new CarStore("小卡車",2000,0,5),

new CarStore("大卡車",5000,0,15),

};

System.out.println("歡迎來到達達租車,如果您想租車請按Y,不想租車請按N");

Scanner input=new Scanner(System.in);

String a=input.next();

if(a.equals("y")) {

System.out.println("序號? ? ? ? ? ? ?車名? ? ? ? ? ?每天租金? ? ?載人數? ? 載貨數");

for(int i=0;i<CarList.length;i++) {

System.out.println("序列號:"+i+"\t"+CarList[i].getname()

+"\t"+CarList[i].getjine()

+"\t"+CarList[i].getzairenliang()

+"\t"+CarList[i].getzaihuoliang());

}

System.out.println("請輸入需要的車輛數:");

int b=input.nextInt();

for(int c=1;c<=b;c++) {

System.out.println("請輸入第"+c+"輛車的序號");

int d=input.nextInt();

switch(d){


? ? case 0:


? ? sum+=2000;

? ? zzhl+=0;

? ? ? ? zzkl+=5;

? ? break;

? ??

? ? case 1:


? ? sum+=2500;

? ? zzhl+=0;

? ? zzkl+=5;

? ? break;


? ? case 2:


? ? sum+=800;

? ? zzhl+=0;

? ? zzkl+=12;

? ? break;


? ? case 3:


? ? sum+=8000;

? ? zzhl+=0;

? ? zzkl+=2;

? ? break;


? ? case 4:


? ? sum+=2000;

? ? zzhl+=5;

? ? zzkl+=0;

? ? break;


? ? case 5:

? ?

? ? sum+=5000;

? ? ? ? zzhl+=15;

? ? ? ? zzkl+=0;

? ? }

}

System.out.println("請輸入租車天數:");

int e=input.nextInt();

sum=sum*e;

System.out.println("總金額為:"+sum+"\n"+"總載貨量:"+zzhl+"\n"+"總載客量:"+zzkl);

}

}

}


正在回答

1 回答

我覺你的簡單易懂,我試了一下你的程序,有個不好的地方:進入租車系統提示語句,應該寫成"歡迎來到達達租車,如果您想租車請輸入y,不想租車請輸入n",這樣更易懂。

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

舉報

0/150
提交
取消

看了別人的自己才有點思路,我的應該是最簡單易懂的了,就是感覺沒用上第二季的知識

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

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

幫助反饋 APP下載

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

公眾號

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