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

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

正在回答

3 回答

package java22;

import java.util.*;

import java.util.Scanner;?

public class RentCar {

public static void main(String[] args) {

System.out.println("歡迎使用答答租車系統(tǒng):");

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

boolean withDraw2 = true,withDraw3 = true,withDraw4 = true;

Scanner strRent = new Scanner(System.in); //第1次輸入,是否租車

if(strRent.hasNext()){? ?

String Rent = strRent.nextLine();

//System.out.println(Rent);

if(Rent.equals("1")){

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

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

? ? ? ? System.out.println("1.? ?奧迪A4? ? ? ?500元/天? ?載人:4人");//載人 1-4人,2-4人,3-4人,4-20人

? ? ? ? System.out.println("2.? ?馬自達(dá)6 ? 400元/天? ?載人:4人");//載貨 3-2噸,5-4噸,6-20噸

? ? ? ? System.out.println("3.? ?皮卡雪6? ? ? 450元/天? ? 載人:4 載貨:2噸");

? ? ? ? System.out.println("4.? ?金龍 ? 800元/天? ?載人:20人");

? ? ? ? System.out.println("5.? ?松花江? ? ? ? ? ? 400元/天? ?載貨:4噸");

? ? ? ? System.out.println("6.? ?依維柯? ? ? ? ? ? 1000元/天 載貨:20噸");

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

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

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

//? ? ? ? System.out.println("1.奧迪A4\t500元/天\t載人:4人");//載人 1-4人,2-4人,3-4人,4-20人

//? ? ? ? System.out.println("2.馬自達(dá)6\t400元/天\t載人:4人");//載貨 3-2噸,5-4噸,6-20噸

//? ? ? ? System.out.println("3.皮卡雪6\t450元/天\t載人:4 載貨:2噸");

//? ? ? ? System.out.println("4.金龍\t800元/天\t載人:20人");

//? ? ? ? System.out.println("5.松花江\t400元/天\t載貨:4噸");

//? ? ? ? System.out.println("6.依維柯\t1000元/天\t載貨:20噸");

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

? ? ? ? Rent = null;? ? ? ?

? ? ? ? Scanner strRentNumber = new Scanner(System.in); //第2次輸入,租幾輛

? ? ? ? if(strRentNumber.hasNext()){

? ? ? ? String RentNumber = strRentNumber.nextLine();

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

? ? ? ? if(withDraw2 == true){

? ? ? ? if (!Character.isDigit(RentNumber.charAt(i))){

? ? ? ? System.out.println("非法輸入!");

? ? ? ? withDraw2 = false;

? ? ? ? break;

? ? ? ? }

? ? ? ? }else{break;}

? ? ? ? }

? ? ? ? if(withDraw2 == true){

? ? ? ? int rentNumber = Integer.parseInt(RentNumber);? ? ? ?

? ? ? ? int[] rentCar = new int[rentNumber + 1];

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

? ? ? ? rentCar[i] = 0;

? ? ? ? }

? ? ? ? int j = 1,i = 1;

? ? ? ? while(j <= rentNumber){

? ? ? ? if(withDraw3 == true){

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

? ? ? ? Scanner strCarType = new Scanner(System.in);//第3次輸入,租哪輛車

? ? ? ? if(strCarType.hasNext()){

? ? ? ? String CarType = strCarType.nextLine();

? ? ? ? for (i = 0; i < CarType.length(); i++){? ? ? ?

? ? ? ? ? ? ? ? if (!Character.isDigit(CarType.charAt(i))){

? ? ? ? ? ? ? ? System.out.println("非法輸入!");

? ? ? ? ? ? ? ? withDraw3 = false;

? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ?if(withDraw3 == true){

? ? ? ? int carType = Integer.parseInt(CarType);

? ? ? ? rentCar[j] = carType;

? ? ? ? if(rentCar[j] < 1 || rentCar[j] > 6)

? ? ? ? ? ? {?

? ? ? ? System.out.println("非法輸入!");

? ? ? ? System.out.println( "沒有" + rentCar[j] + "型車。");

? ? ? ? System.out.println("再見!");

? ? ? ? withDraw3 = false;

? ? ? ? }

? ? ? ? ? ? ? ?}

? ? ? ? ? ? ? ?}

? ? ? ?

? ? ? ? }else{break;}

? ? ? ? j++;

? ? ? ? }

? ? ? ? if(withDraw3 == true){

? ? ? ? double cost = 0.0,load = 0.0;

? ? ? ? int manned = 0;

? ? ? ? for(i = 1; i <= rentNumber;i++){

? ? ? ? if(rentCar[i] > 0){

? ? ? ? switch (rentCar[i]){

? ? ? ? case 0:break;

? ? ? ? case 1:cost += 500;manned += 4;break;

? ? ? ? case 2:cost += 400;manned += 4;break;

? ? ? ? case 3:cost += 450;manned += 4;load += 2;break;

? ? ? ? case 4:cost += 800;manned += 20;break;

? ? ? ? case 5:cost += 400;load += 4;break;

? ? ? ? case 6:cost += 1000;load += 20;break;

? ? ? ? default:break;

? ? ? ? }

? ? ? ? ? ?}

? ? ? ? }

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

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

? ? ? ? if(strDays.hasNext()){

? ? ? ? String RentDays = strDays.nextLine();

? ? ? ? for ( i = 0; i < RentDays.length(); i++){? ? ? ?

? ? ? ? ? ? if (!Character.isDigit(RentDays.charAt(i))){

? ? ? ? ? ? System.out.println("非法輸入!");

? ? ? ? ? ? withDraw4 = false;

? ? ? ? ? ? break;

? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? if(withDraw4 == true){

? ? ? ? int rentDays = Integer.parseInt(RentDays);?

? ? ? ? cost *= rentDays;

? ? ? ? }

? ? ? ? }

? ? ? ? if(withDraw4 == true){

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

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

? ? ? ? if(manned == 0){

? ? ? ? System.out.println("無");

? ? ? ? }

? ? ? ? else{

? ? ? ? ? for(i = 1;i <= rentNumber;i++){

? ? ? ? if(rentCar[i] > 0){

? ? ? ? if (rentCar[i] == 1||rentCar[i] == 2||rentCar[i] == 3||rentCar[i] == 4){

? ? ? ? switch(rentCar[i]){

? ? ? ? case 1:System.out.print("奧迪A4" + " ");break;

? ? ? ? case 2:System.out.print("馬自達(dá)6" + " ");break;

? ? ? ? case 3:System.out.print("皮卡雪6" + " ");break;

? ? ? ? case 4:System.out.print("金龍" + " ");break;? ? ? ?

? ? ? ? default:break;

? ? ? ? }

? ? ? ? }

? ? ? ? }? ? ? ?

? ? ? ? }

? ? ? ? }

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

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

? ? ? ? if(load == 0){

? ? ? ? System.out.println("無");

? ? ? ? }

? ? ? ? else{

? ? ? ? ? for(i = 1;i <= rentNumber;i++){

? ? ? ? if(rentCar[i] > 0){

? ? ? ? if (rentCar[i] == 3||rentCar[i] == 5||rentCar[i] == 6){

? ? ? ? switch(rentCar[i]){

? ? ? ? case 3:System.out.print("皮卡雪6" + " ");break;? ? ? ?

? ? ? ? case 5:System.out.print("松花江" + " ");break;

? ? ? ? case 6:System.out.print("依維河" + " ");break;

? ? ? ? default:break;

? ? ? ? }

? ? ? ? }

? ? ? ? ? }? ? ? ?

? ? ? ? ? ?}

? ? ? ? }

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

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

? ? ? ? System.out.println("賬單計(jì)算結(jié)束.感謝您的光臨,祝您生活愉快!");

? ? ? ? }

? ? ? ? }

? ? ? ? }

? ? ? ? }

}else if(Rent.equals("0"))

? {

System.out.println("ByeBye!");

? }else{

? System.out.println("非法輸入!再見!");

? }? ? ? ?

}

}

}


面向?qū)ο蟮拇a被我寫成面向過程的,我對(duì)我也是...有點(diǎn)醉

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

雖然我覺得大家應(yīng)該自己動(dòng)手解決思考。但是老師也要寫一遍出來讓我們參考講解一下把。就像是把這個(gè)問題 實(shí)例化解決一下看看. 按照上一節(jié)的項(xiàng)目思考方式 一步一步的構(gòu)建編寫出完整的代碼,幫助同學(xué)們養(yǎng)成良好的編寫習(xí)慣與思維方式。? ?我還是參考同學(xué)的代碼 了解到自己之前學(xué)的不扎實(shí)。例如 有參的構(gòu)造方法,循環(huán),判斷等 但是多數(shù)同學(xué)都只是把代碼寫出來,沒注釋,沒思路圖。這樣看起來很費(fèi)勁. 我是零基礎(chǔ).課程也是針對(duì)零基礎(chǔ)。希望理解。

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

太多了,視頻里面寫出來費(fèi)時(shí)間

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

舉報(bào)

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

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

進(jìn)入課程

搭搭租車系統(tǒng)

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