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

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

租車系統(tǒng),小白一個(gè),,過程有點(diǎn)亂,望高手們指點(diǎn)指點(diǎn)。

import java.util.Scanner;

public class Car?

{

Scanner in=new Scanner(System.in);

int q,b,d,l,a,o,k,cs=0,p=0;//cs表示載人的累加值。p表示可載貨車輛的累加值。

double s,count=0,ds=0;//count表示租金的累加值。ds表示噸位的累加值。

public Ddffdsf(int newA) ?//構(gòu)造方法初始化a值

? {

a=newA;

?}

?public void cl()

?{

if(a==1) ?//當(dāng)a為1時(shí)輸出以下表格并調(diào)用本類中的cc方法

? { ? ??

System.out.println("您可租車的類型及其價(jià)目表:");

System.out.println("序號(hào) ? ? ?汽車名稱 ? ? ? ? ? ? ? 租金 ? ? ? ? ? ? ? ? ? ? ? ? ? 容量");

? ?System.out.println(" 1 ? ? 奧迪A8 ? ? 10000元/天 ? ? ? ? ? ?載人:2人");

? ?System.out.println(" 2 ? ? 蘭博基尼 ? ? ? ?12220元/天 ? ? ? ? ? ?載人:2人");

? ?System.out.println(" 3 ? ? 奔馳S600 ? ?9000元/天 ? ? ? ? ? ?載人:5人");

? ?System.out.println(" 4 ? ? 寶馬M8 ? ? ?9999元/天 ? ? ? ? ? ?載人:4人");

? ?System.out.println(" 5 ? ? 皮卡 ? ? ? ? ? ? ? ? ?888元/天 ? ? ? ? ? ? ? 載人:4人 ? 可載貨:2噸");

? ?System.out.println(" 6 ? ? 林肯加長(zhǎng) ? ? ? ?22222元/天 ? ? ? ? ? ?載人:12人");

? ?System.out.println(" 7 ? ? 法拉利 ? ? ? ? ? ?77777元/天 ? ? ? ? ? ?載人: 2人");

? ?System.out.println(" 8 ? ? 一汽卡車 ? ? ? ? ? 777元/天 ? ? ? ? ? ? 載人: 2人 ?可載貨:10噸");

? ?cc();

? }

else ? ?//當(dāng)輸入的數(shù)不是1時(shí),輸出"歡迎下次光臨!"。

? {

System.out.println("歡迎下次光臨!");

? ? ? ? ? ?}

?}

? public void cc()

? ? ? {

? System.out.print("請(qǐng)輸入您要租汽車的數(shù)量:");

? ? ? ? b=in.nextInt(); ? ? ? //讀取一個(gè)整數(shù)

? ? ?if(b>0) ? ? ? ? ? ? ?//b如果大于0

? ? ? ? ?{

? ? this.b=b; ? ? ? ? //把讀取的b賦值給this.b

? ? for(int i=0;i<b;i++) ? ? //使用for循環(huán)讓用戶輸入要選擇車輛的序號(hào)

? {

? System.out.print("請(qǐng)輸入第"+(i+1)+"輛汽車的序號(hào):");

? ? ? ? q=in.nextInt(); ? //讀取用戶輸入的序號(hào)

?if(q<=0|q>8) ? ? ?//如果用戶輸入的序號(hào)不在系統(tǒng)規(guī)定的范圍內(nèi),則運(yùn)行大括號(hào)里面的代碼

? ? { ?

? ? ? ? while(q<=0|q>8) ? //則使用while循環(huán) 以提示用戶重新輸入,只有重新輸入的序號(hào)在規(guī)定的范圍內(nèi),循環(huán)才會(huì)結(jié)束。

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //這樣避免輸入錯(cuò)誤后又要重新運(yùn)行系統(tǒng)

? ? ? ? { ? ? ? ? ? ? ? ? ?

? ? ? ? System.out.println("您輸入的序號(hào)錯(cuò)誤,請(qǐng)重新輸入。");

? ? ? ? System.out.print("請(qǐng)輸入第"+(i+1)+"輛汽車的序號(hào):");

? ? ? ? ? ?q=in.nextInt(); ?

? ? ? ? } ? ? ? ? ? ? ? ? ? ?//如果重新輸入的序號(hào)在規(guī)定的范圍內(nèi),則系統(tǒng)會(huì)進(jìn)行判斷,進(jìn)行配對(duì)和運(yùn)算

? ? ? ? if(q==1){d=2;s=10000;count=count+s;cs=cs+d;}

? ? ? ? if(q==2){d=2;s=12220;count=count+s;cs=cs+d;}

? ? ? ? if(q==3){d=5;s=9000;count=count+s;cs=cs+d;}

? ? ? ? if(q==4){d=4;s=9999;count=count+s;cs=cs+d;}?

? ? ? ? if(q==5){d=4;k=2;s=888;count=count+s;cs=cs+d;ds=ds+k;p++;}?

? ? ? ? if(q==6){d=12;s=22222;count=count+s;cs=cs+d;}?

? ? ? ? if(q==7){d=2;s=77777;count=count+s;cs=cs+d;}

? ? ? ? if(q==8){d=2;k=10;s=777;count=count+s;cs=cs+d;ds=ds+k;p++;}

? ? ? ? ? ? ?}?

? ? ? ? else ? ? ? ? ? ? ? ? //如果用戶輸入序號(hào)在系統(tǒng)規(guī)定的范圍內(nèi),則運(yùn)行大括號(hào)里面的代碼,進(jìn)行累加運(yùn)算

? ? ? ? ? ? ? ? {

? ? ? ? if(q==1){d=2;s=10000;count=count+s;cs=cs+d;}

? ? ? ? if(q==2){d=2;s=12220;count=count+s;cs=cs+d;}

? ? ? ? if(q==3){d=5;s=9000;count=count+s;cs=cs+d;}

? ? ? ? if(q==4){d=4;s=9999;count=count+s;cs=cs+d;}?

? ? ? ? if(q==5){d=4;k=2;s=888;count=count+s;cs=cs+d;ds=ds+k;p++;}?

? ? ? ? if(q==6){d=12;s=22222;count=count+s;cs=cs+d;}?

? ? ? ? if(q==7){d=2;s=77777;count=count+s;cs=cs+d;}

? ? ? ? if(q==8){d=2;k=10;s=777;count=count+s;cs=cs+d;ds=ds+k;p++;} ? ? ? ??

? ? ? ? ? ? ? ? } ? ? ?

? ? ? ? ? ?} ? ? ? ? ? ? ? ??

? ? System.out.print("請(qǐng)輸入租車天數(shù):");

? ? ? ? ? ?l=in.nextInt(); ??

? ? ? ? ? ?if(l>0) ? ? ? ? ? ? //如果讀取的天數(shù)大于0,則運(yùn)行大括號(hào)里面的代碼

? ? {

? ? ? ? ? this.l=l; ? ?//將讀取到的天數(shù)l賦值給this.l

? ? ? ? if(ds>0) ? ? ?//判斷噸位的累加值是否大于0,如果大于0則最終輸出會(huì)帶有噸位和提示可載貨的車輛有多少

? ? ? ? ? {

? ?System.out.println("您需支付"+count*l+"元"+" ? "+"總共可載客人數(shù)為:"+cs+"人"+"可載貨的車輛有:"+p+"輛"+" ? "+"其中總可載貨"+ds+"噸");?

? ?System.out.println("歡迎您下次光臨!");

? ? ? ? ? }?

? ? ? ? else //如果噸位的累加值小于或等于0,則最終輸出就只有總載人數(shù)和價(jià)格

? ?{

? ? System.out.println("您需支付"+count*l+"元"+" ? "+"總共可載客人數(shù)為:"+cs+"人");

System.out.println("歡迎您下次光臨!");

? ?}

? ? ?}

? ? ? ? ? else ? //這個(gè)else代表如果用戶輸入租車的天數(shù)小于0,就也會(huì)進(jìn)入一個(gè)while循環(huán),提示用戶重新輸入租車天數(shù)。

? ? ? ? ? ? ? ? ?//這樣也可以避免到輸入天數(shù)的時(shí)候,輸入錯(cuò)誤時(shí),不會(huì)導(dǎo)致又要再次運(yùn)行系統(tǒng)重新開始。

? ? ? ? ? {

? ? ? ? ? while(l<=0)

? ? ? ? ? ? ? {

? ? ? ? ? System.out.println("您輸入租車天數(shù)的數(shù)據(jù)有誤,請(qǐng)重新輸入。");?

? ? ? ? ? ? l=in.nextInt();

? ? ? ? ? }?

? ? ? ? ? this.l=l; ?//當(dāng)重新輸入的租車天數(shù)不滿足while循環(huán)的條件時(shí),就會(huì)把l值賦值給this.l

? ? ? ? ? if(ds>0) ??

? {

? ?System.out.println("您需支付"+count*l+"元"+" ? "+"總共可載客人數(shù)為:"+cs+"人"+"可載貨的車輛有:"+p+"輛"+" ? "+"其中總可載貨:"+ds+"噸");?

? ?System.out.println("歡迎您下次光臨!");

? }

? ? ? ? ? else

? ? ? ? {

? ? ? ? ? ?System.out.println("您需支付"+count*l+"元"+" ? "+"總共可載客人數(shù)為:"+cs+"人");

? ? ? ?System.out.println("歡迎您下次光臨!"); ?

? ? ? ? } ?

? ? ? ? ? }

? ? ? ? ?}

? ? ?else ? ? ?//表示如果剛開始輸入的數(shù)量b小于等于0

? ? ? ? ? //再次利用while循環(huán)

? ? ? {

? ? ?while(b<=0)

? ? ?{

? ? ?System.out.println("您輸入租汽車的數(shù)量數(shù)據(jù)有誤,請(qǐng)重新輸入。");

? ? ?b=in.nextInt();

? ? ?}

? ? ?this.b=b; //因?yàn)橹匦螺斎氲臄?shù)量b大于0,所以就得從獲取序號(hào)這步繼續(xù)運(yùn)行下去

? ? ?for(int i=0;i<b;i++)

? ? ? ? ? ? ? ? ? ?{

? System.out.print("請(qǐng)輸入第"+(i+1)+"輛汽車的序號(hào):");

? ? ? ? q=in.nextInt();

? ? ? ? if(q<=0|q>8) ??

? ? ? ? ? ? { ?

? ? ? ? while(q<=0|q>8)//當(dāng)重新輸入的數(shù)量正確時(shí),接下來(lái)序號(hào)輸入錯(cuò)誤,那么就用while循環(huán)提示用戶修改,直到正確才執(zhí)行下一步

? ? ? ? ? {

? ? ? ? System.out.println("您輸入的序號(hào)錯(cuò)誤,請(qǐng)重新輸入。");

? ? ? ? System.out.print("請(qǐng)輸入第"+(i+1)+"輛汽車的序號(hào):");

? ? ? ? q=in.nextInt();

? ? ? }

? ? ? ? if(q==1){d=2;s=10000;count=count+s;cs=cs+d;}

? ? ? ? if(q==2){d=2;s=12220;count=count+s;cs=cs+d;}

? ? ? ? if(q==3){d=5;s=9000;count=count+s;cs=cs+d;}

? ? ? ? if(q==4){d=4;s=9999;count=count+s;cs=cs+d;}?

? ? ? ? if(q==5){d=4;k=2;s=888;count=count+s;cs=cs+d;ds=ds+k;p++;}?

? ? ? ? if(q==6){d=12;s=22222;count=count+s;cs=cs+d;}?

? ? ? ? if(q==7){d=2;s=77777;count=count+s;cs=cs+d;}

? ? ? ? if(q==8){d=2;k=10;s=777;count=count+s;cs=cs+d;ds=ds+k;p++;}

? ? ? ? ? ? }?

? ? ? ? else ? //重新輸入數(shù)量b正確后,輸入序號(hào)也在系統(tǒng)的范圍內(nèi),則執(zhí)行這一步

? ? ? ? ? ? ? ? {

? ? ? ? if(q==1){d=2;s=10000;count=count+s;cs=cs+d;}

? ? ? ? if(q==2){d=2;s=12220;count=count+s;cs=cs+d;}

? ? ? ? if(q==3){d=5;s=9000;count=count+s;cs=cs+d;}

? ? ? ? if(q==4){d=4;s=9999;count=count+s;cs=cs+d;}?

? ? ? ? if(q==5){d=4;k=2;s=888;count=count+s;cs=cs+d;ds=ds+k;p++;}?

? ? ? ? if(q==6){d=12;s=22222;count=count+s;cs=cs+d;}?

? ? ? ? if(q==7){d=2;s=77777;count=count+s;cs=cs+d;}

? ? ? ? if(q==8){d=2;k=10;s=777;count=count+s;cs=cs+d;ds=ds+k;p++;}

? ? ? ? ? ? ? ? }

? ? ? ?System.out.print("請(qǐng)輸入租車天數(shù):");

? ? ? ? ? ?l=in.nextInt();

? ? ? ? ? ?if(l>0)//重新輸入數(shù)量b正確后,輸入序號(hào)也在系統(tǒng)的范圍內(nèi),接下來(lái)的租車天數(shù)輸入的值也正確,則執(zhí)行這一步

? ? ? ? ? ? ? {

? ? ? ? ? this.l=l;

? ? ? ? ? if(ds>0)

? ? ? ? ? {

? ?System.out.println("您需支付"+count*l+"元"+" ? "+"總共可載客人數(shù)為:"+cs+"人"+" ?"+"其中可載貨的車輛有:"+p+"輛"+" ? "+"總可載貨:"+ds+"噸");?

? ?System.out.println("歡迎您下次光臨!");

? ? ? ? ? }else?

? ? ? ? ? ? ?{

? System.out.println("您需支付"+count*l+"元"+" ? "+"總共可載客人數(shù)為:"+cs+"人");

System.out.println("歡迎您下次光臨!");?

? ? ? ? ? ? ?}?

? ? ? ? ? ? ? ? ? ? }

else //重新輸入數(shù)量b正確后,輸入序號(hào)也在系統(tǒng)的范圍內(nèi),接下來(lái)的租車天數(shù)輸入的值不正確,則執(zhí)行這一步

?//利用while循環(huán)提示用戶進(jìn)行修改

{

? ?while(l<=0)

? ? ? ? {

System.out.println("您輸入租車天數(shù)的數(shù)據(jù)有誤,請(qǐng)重新輸入。");?

l=in.nextInt();

? ? ? ? }?

? this.l=l;

? if(ds>0)

? ? ? ?{

? ? ? System.out.println("您需支付"+count*l+"元"+" ? "+"總共可載客人數(shù)為:"+cs+"人"+" ?"+"其中可載貨的車輛有:"+p+"輛"+" ? "+"總可載貨:"+ds+"噸");

? ? ? System.out.println("歡迎您下次光臨!");

? ? ? ? ? ? ? ?}

? else?

? ? ? ? ? {

? ? System.out.println("您需支付"+count*l+"元"+" ? "+"總共可載客人數(shù)為:"+cs+"人");

System.out.println("歡迎您下次光臨!");

? ? ? }

? }

? ? ? ? } ? ? ? ?

?} ? ? ??

? ? ? }

}?

**********************************************************

//創(chuàng)建第二個(gè)類,名稱為Main,在main函數(shù)里調(diào)用Car中的cl方法

public class Main {

public static void main(String[] args) {

int a;

Scanner in=new Scanner(System.in);

System.out.println("歡迎光臨飛騰租車!");

System.out.println("是否需要租車:1是 0否");

? a=in.nextInt();

? Car b=new Car(a); ? ? ??

? ? ? ?b.cl(); ? ?

}

}


正在回答

1 回答

其實(shí)我也不懂。。就亂改,2個(gè)地方

?Car b= new Car();

? ? ? b.cl(a);?

還有就是

public void cl(int i)

?{

if(i==1)

不曉得是不是你想要的效果

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

舉報(bào)

0/150
提交
取消

租車系統(tǒng),小白一個(gè),,過程有點(diǎn)亂,望高手們指點(diǎn)指點(diǎn)。

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

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

幫助反饋 APP下載

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

公眾號(hào)

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