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

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

為什么綜合練習(xí)的名字始終是null呢?

package com.imooc.test7;


import java.util.Scanner;


public class Test {


public static void main(String[] args) {

// TODO Auto-generated method stub

//創(chuàng)建車輛信息

Car[] car = {new PessagerCar("奧迪A4 ", 500, 4),new CargoCar("松花江", 400, 4),new PukiCar("皮卡雪6", 450, 4,2)};

System.out.println("歡迎來到租車地帶!");

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

//顯示租車信息

Scanner in = new Scanner(System.in);

int choice = in.nextInt();

while(choice != 2 || choice !=1){

//如果輸入錯誤,非0/1,則重新輸入

if(choice == 1){

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

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

int i =0;

for(Car curCar:car){ //定義一個curCar對象遍歷car數(shù)組

i++;

if(curCar instanceof PessagerCar){

System.out.println("" + i + "\t" + curCar.getName() + "\t" ?+ curCar.getRent() + "元/輛"+ "\t"+ ((PessagerCar) curCar).getManned() + "人");

//car[i].show(); ?//顯示租車信息及序號

}

if(curCar instanceof CargoCar){

System.out.println("" + i + "\t" + curCar.getName() + "\t" + curCar.getRent() + "元/輛" +"\t"+ ((CargoCar) curCar).getCargo() + "噸");

}

if(curCar instanceof PukiCar){

System.out.println("" + i + "\t" + curCar.getName() + "\t" + curCar.getRent() + "元/輛" +"\t"+ ((PukiCar) curCar).getManned() + "人" + ((PukiCar) curCar).getCargo() + "噸");

}

}

break;

}else{

System.out.println("謝謝你的光臨,再見!");

}

}

//租車數(shù)量

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

int carnum = in.nextInt();

Car[] choicecar = new Car[carnum]; //將選擇的序號存入數(shù)組

for(int i = 0;i < carnum ;i++){

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

int num = in.nextInt();

choicecar[i] = car[num-1];

}

//租車天數(shù)

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

int rentday = in.nextInt();

//計算并顯示賬單

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

int allmoney = 0;//總的租金

System.out.println("您總共要租借"+rentday+"天");

//計算總載客數(shù)載貨量

int allPesCar = 0; ?//總載人數(shù)

int allCargo = 0; ? //總載貨量

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

if(choicecar[i] instanceof PessagerCar){

allPesCar += ((PessagerCar) choicecar[i]).getManned();

allmoney += ((PessagerCar) choicecar[i]).getRent();

}

if(choicecar[i] instanceof CargoCar){

allCargo += ((CargoCar) choicecar[i]).getCargo();

allmoney += ((CargoCar) choicecar[i]).getRent();

}

if(choicecar[i] instanceof PukiCar){

allPesCar += ((PukiCar) choicecar[i]).getManned();

allCargo +=((PukiCar)choicecar[i]).getCargo();

allmoney += ((PessagerCar) choicecar[i]).getRent();

allmoney += ((CargoCar) choicecar[i]).getRent();

}

}

//輸出清單

System.out.println("您所要租借的總載客量為: " + allPesCar + "人\t" + "總載貨量為:" + allCargo + "噸");

? ? ? ? int totalPrice = allmoney*rentday; ? //總價

? ? ? ? System.out.println("您總共需要支付: ?" + totalPrice ?+ " ?元");

? ? ? ? System.out.println("謝謝光臨租車地帶,下次再見!");

}

}


正在回答

2 回答

http://img1.sycdn.imooc.com//56ed0484000118b505520368.jpg并沒有錯誤信息
0 回復(fù) 有任何疑惑可以回復(fù)我~

可以把報錯信息貼上來么?

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

舉報

0/150
提交
取消
Java入門第二季 升級版
  • 參與學(xué)習(xí)       531100    人
  • 解答問題       6280    個

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

進(jìn)入課程

為什么綜合練習(xí)的名字始終是null呢?

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

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

幫助反饋 APP下載

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

公眾號

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