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

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

我寫的答答打車,歡迎指導(dǎo)

import java.util.Scanner;

public class Initial {


public static void main(String[] args) {

// TODO 自動(dòng)生成的方法存根

? ? ? ?Peoplecar car1=new Peoplecar("奧迪A4",500,4,0);

? ? ? ?Peoplecar car2=new Peoplecar("馬自達(dá)6",400,4,0);

? ? ? ?Pickup ? ?car3=new Pickup("皮卡雪6",450,4,2);

? ? ? ?Peoplecar car4=new Peoplecar("金龍",800,20,0);

? ? ? ?Goodscar ?car5=new Goodscar("松花江",400,0,4);

? ? ? ?Goodscar ?car6=new Goodscar("依維柯",1000,0,20);

? ? ? ?Scanner input=new Scanner(System.in);

? ? ? ?System.out.println("歡迎使用答答租車系統(tǒng):您是否要租車:1是 0否");

? ? ? ?int choose=input.nextInt();//輸入1或者0選擇

? ? ? ?if(choose==1){

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

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

? ? ?System.out.println(1+"\t"+car1.getCarName()+"\t"+car1.getPrice()+"元/天"+"\t"+car1.getBusLoad()+"人"+"\t"+car1.getCarGo()+"噸");

? ? ?System.out.println(2+"\t"+car2.getCarName()+"\t"+car2.getPrice()+"元/天"+"\t"+car2.getBusLoad()+"人"+"\t"+car2.getCarGo()+"噸");

? ? ?System.out.println(3+"\t"+car3.getCarName()+"\t"+car3.getPrice()+"元/天"+"\t"+car3.getBusLoad()+"人"+"\t"+car3.getCarGo()+"噸");

? ? ?System.out.println(4+"\t"+car4.getCarName()+"\t"+car4.getPrice()+"元/天"+"\t"+car4.getBusLoad()+"人"+"\t"+car4.getCarGo()+"噸");

? ? ?System.out.println(5+"\t"+car5.getCarName()+"\t"+car5.getPrice()+"元/天"+"\t"+car5.getBusLoad()+"人"+"\t"+car5.getCarGo()+"噸");

? ? ?System.out.println(6+"\t"+car6.getCarName()+"\t"+car6.getPrice()+"元/天"+"\t"+car6.getBusLoad()+"人"+"\t"+car6.getCarGo()+"噸");

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

? ? ? ? ?int score=input.nextInt();//輸入要租用的數(shù)量信息

? ? ? ? ?String nsum1="";//初始化屬性

? ? ? ? ?String nsum2="";//初始化屬性?

? ? ? ? ?String nsum3="";//初始化屬性

? ? ? ? ?String nsum4="";//初始化屬性

? ? ? ? ?String nsum5="";//初始化屬性

? ? ? ? ?String nsum6="";//初始化屬性

? ? ? ? ?int psum=0;//初始化屬性

? ? ? ? ?double hsum=0;//初始化屬性

? ? ? ? ?double jsum=0;//初始化屬性

? ? ? ? ?for(int i=1;i<=score;i++){

? ? ? ? //通過(guò)租用數(shù)量信息score定義循環(huán)的最大值

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

? ? ? ? int a=input.nextInt();//通過(guò)輸入選擇合適值與入口匹配運(yùn)算

? ? ? ? if(a>=1&&a<=6){

? ? ? ? ? ? ? if(a==1){//輸入值等于1時(shí)執(zhí)行下面語(yǔ)句

? ? ? ? ? ? ? nsum1=car1.getCarName();

? ? ? ? ? ? ? jsum+=car1.getPrice();

? ? ? ? ? ? ? ? ? psum+=car1.getBusLoad();

? ? ? ? ? ? ? }

? ? ? ? ? ? ? if(a==2){//輸入值等于2時(shí)執(zhí)行下面語(yǔ)句

? ? ? ? ? ? ? nsum2=car2.getCarName();

? ? ? ? ? ? ? jsum+=car2.getPrice();

? ? ? ? ? ? ? ? ? psum+=car2.getBusLoad();

? ? ? ? ? ? ? }

? ? ? ? ? ? ? if(a==3){//輸入值等于3時(shí)執(zhí)行下面語(yǔ)句

? ? ? ? ? ? ? nsum3=car3.getCarName();

? ? ? ? ? ? ? jsum+=car3.getPrice();

? ? ? ? ? ? ? ? ? psum+=car3.getBusLoad();

? ? ? ? ? ? ? ? ? hsum+=car3.getCarGo();

? ? ? ? ? ? ? }

? ? ? ? ? ? ? if(a==4){//輸入值等于4時(shí)執(zhí)行下面語(yǔ)句

? ? ? ? ? ? ? nsum4=car4.getCarName();

? ? ? ? ? ? ? jsum+=car4.getPrice();

? ? ? ? ? ? ? ? ? psum+=car4.getBusLoad();

? ? ? ? ? ? ? }

? ? ? ? ? ? ? if(a==5){//輸入值等于5時(shí)執(zhí)行下面語(yǔ)句

? ? ? ? ? ? ? nsum5=car5.getCarName();

? ? ? ? ? ? ? jsum+=car5.getPrice();

? ? ? ? ? ? ? ? ? hsum+=car5.getCarGo();

? ? ? ? ? ? ? }

? ? ? ? ? ? ? if(a==6){//輸入值等于6時(shí)執(zhí)行下面語(yǔ)句

? ? ? ? ? ? ? nsum6=car6.getCarName();

? ? ? ? ? ? ? ? ? jsum+=car6.getPrice();

? ? ? ? ? ? ? ? ? hsum+=car6.getCarGo();

? ? ? ? ? ? ? }

? ? ? ? }else{

? ? ? ? System.out.println("輸入值有錯(cuò)誤!");

? ? ? ? System.exit(0);//退出所有程序

? ? ? ? }

? ? ? ? ? ? ? }

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

? ? ? ? ?int b=input.nextInt();//租用天數(shù)并賦值給b

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

? ? ? ? ?System.out.println("***可載人的車有:");

? ? ? ? ?//在此輸出只要執(zhí)行過(guò)的再次賦值的載人車輛名稱

? ? ? ? ?System.out.println(nsum1+"\t"+nsum2+"\t"+nsum3+"\t"+nsum4);

? ? ? ? ?System.out.println("共載人:"+psum+"人");

? ? ? ? ?System.out.println("***載貨的車有:");

? ? ? ? ?//在此輸出只要執(zhí)行過(guò)的再次賦值的載貨車輛名稱

? ? ? ? ?System.out.println(nsum3+"\t"+nsum5+"\t"+nsum6);

? ? ? ? ?//因?yàn)槊看味荚谙嗉?,所以最后循環(huán)出來(lái)的就是總量

? ? ? ? ?System.out.println("共載貨:"+hsum+"噸");

? ? ? ? ?jsum=jsum*b;//因?yàn)閮r(jià)格每次循環(huán)沒(méi)有清零,所以一直相加一起,再此處乘以天數(shù)即可

? ? ? ? ?System.out.println("***租車總價(jià)格:"+jsum+"元");

? ? ? ? ?}

? ? ? ? ?if(choose==0){

? ? ? System.out.println("正在退出系統(tǒng),歡迎下次再來(lái)!");

? ? ? ?}else{

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

? ? ? ?}

}

}


  • 作者: 慕粉小蝸牛?
    完整鏈接:http://idcbgp.cn/article/8889
    來(lái)源:慕課網(wǎng)
    本文原創(chuàng)發(fā)布于慕課網(wǎng) ,禁止轉(zhuǎn)載

正在回答

7 回答

? ? ? ?Scanner input=new Scanner(System.in);

? ? ? ?System.out.println("歡迎使用答答租車系統(tǒng):您是否要租車:1是 0否");

? ? ? ?int choose=input.nextInt();//輸入1或者0選擇



這里String類型可以直接轉(zhuǎn)換成int型嗎?

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

慕粉小蝸牛 提問(wèn)者

輸入的是整數(shù)型
2016-06-13 回復(fù) 有任何疑惑可以回復(fù)我~
#2

慕粉小蝸牛 提問(wèn)者

string是一種引用數(shù)據(jù)類型,單純輸入個(gè)整型用int就行了,還有string a="2";int b=2;區(qū)別
2016-06-13 回復(fù) 有任何疑惑可以回復(fù)我~

對(duì)象建議寫出數(shù)組形式,不用寫那么多的引用,之后的遍歷直接一個(gè)for()循環(huán)就可以了,比較簡(jiǎn)潔。

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

if else 里面有點(diǎn)小問(wèn)題


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

看錯(cuò)了


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

你這樣寫要是a=50,你怎么辦

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

和我寫的還挺像的,哈哈

問(wèn)一句,下面句代碼什么意思? 感覺(jué)有點(diǎn)不太對(duì)勁哦~

?//在此輸出只要執(zhí)行過(guò)的再次賦值的載人車輛名稱

? ? ? ? ?System.out.println(nsum1+"\t"+nsum2+"\t"+nsum3+"\t"+nsum4);


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

慕粉小蝸牛 提問(wèn)者

相當(dāng)于跳格,就是留出位置,你可以試試
2016-06-17 回復(fù) 有任何疑惑可以回復(fù)我~
#2

慕慕4533638 回復(fù) 慕粉小蝸牛 提問(wèn)者

明白了,多謝!
2016-06-20 回復(fù) 有任何疑惑可以回復(fù)我~

厲害!

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

舉報(bào)

0/150
提交
取消
Java入門第二季 升級(jí)版
  • 參與學(xué)習(xí)       531131    人
  • 解答問(wèn)題       6326    個(gè)

課程升級(jí)!以終為始告別枯燥,在開(kāi)發(fā)和重構(gòu)中體會(huì)Java面向?qū)ο缶幊痰膴W妙

進(jìn)入課程

我寫的答答打車,歡迎指導(dǎo)

我要回答 關(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)