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

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

可以了,交作業(yè)

package com;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class HelloWorld {

static Scanner sc = new Scanner(System.in);

static List<Car> clist = new ArrayList<Car>();

static List<Car> rlist = new ArrayList<Car>();

//匿名內(nèi)部類

public class Car{

?String code;//編號

?String name;//名稱

?int money;//每日租金

?int passenger;//載客認(rèn)人數(shù)

?int cargo;//載貨噸位

?int carNum;//租車數(shù)量

?int rentNum;//租賃天數(shù)

?int total;//租金小計

?public Car(String code,String name,int money,int passenger,int cargo){

?this.code=code;

?this.name=name;

?this.money=money;

?this.passenger=passenger;

?this.cargo=cargo;

?}

?public void printInfo(){

System.out.println(this.code+"\t"+this.name+"\t"+this.money+"元 \t"+this.passenger+"\t"+this.cargo);

?}

?public void printResInfo(){

System.out.println(this.code+"\t"+this.name+"\t"+this.money+"元 \t"+this.passenger+"\t"+this.cargo+"\t"+this.carNum+"輛\t"+this.rentNum+"天\t"+this.money*this.rentNum*this.carNum+"元");

?}

}

public static void main(String[] args) {

init(new HelloWorld());//初始化車輛信息

System.out.println("==========歡迎光臨噠噠租車系統(tǒng)==========");

showInfo();

}

//初始化車輛信息

public static void init(HelloWorld obj){

Car c1 = obj.new Car("1","寶馬X1",1000,4,0);

? ? Car c2 = obj.new Car("2","奔馳500",1500,4,0);

? ? Car c3 = obj.new Car("3","東風(fēng)",2000,2,10);

? ? Car c4 = obj.new Car("4","時風(fēng)",500,2,2);

? ? Car c5 = obj.new Car("5","松花江",800,4,20);

? ? Car c6 = obj.new Car("6","金龍",6000,20,0);

? ? clist.add(c1); clist.add(c2); clist.add(c3);

? ? clist.add(c4); clist.add(c5); clist.add(c6);

}

//系統(tǒng)菜單

public static void rent(){

System.out.println("1-退出 \t2-查看車輛信息 \t3-租車 \t4-查看已選租車輛 \t5-重新選擇");

try {

switch (sc.nextInt()) {

? ? ? case 1:

? ? ? if(rlist.size()>0){

? showRes();

? }

? ? ? System.out.println("感謝您的光臨!祝您生活愉快!");

? ? ? break;

? case 2:

? showInfo();

? break;

? case 3:

? getRent();

? break;

? case 4:

? showRes();

? break;

? case 5:

? rlist.clear();

? System.out.println("選租車輛信息已經(jīng)重置!請您選擇接下來的操作服務(wù)編號");

? rent();

? break;

? default:

? System.out.println("您的輸入有誤,請輸入1~5之間的整數(shù)操作服務(wù)編號");

? rent();

break;

?}

}catch (Exception e) {

System.out.println("您的輸入有誤,請輸入1~5之間的整數(shù)操作服務(wù)編號");

rent();

}

}

//展示車輛信息

public static void showInfo(){

? ? System.out.println("------------可租賃的車輛信息-------------");

? ? System.out.println("編號\t名稱\t每日租金 \t載客人數(shù)\t載貨噸位");

? ? for(Car temp:clist){

? ? temp.printInfo();

? ? }

? ? System.out.println("親,請輸入您想要的操作服務(wù)編號(1~5之間的整數(shù))");

? ? rent();

}

//展示已選租車輛信息

public static void showRes(){

if(rlist.size()>0){

? ? System.out.println("------------您已選擇租賃的車輛信息-------------");

? ? System.out.println("編號\t名稱\t每日租金 \t載客人數(shù)\t載貨噸位 \t租車數(shù)量 \t租賃天數(shù) \t租賃金額");

? ? //累計各項數(shù)值

? ? int passNum = 0;//載客總?cè)藬?shù)

? ? int goNum = 0;//載貨總噸位

? ? int carNum = 0;//租車總數(shù)量

? ? int rentNum = 0;//租賃總天數(shù)

? ? double total = 0.0;//租金總額

? ? for(Car temp:rlist){

? ? temp.printResInfo();

? ? passNum+=temp.passenger;

? ? goNum+=temp.cargo;

? ? carNum+=temp.carNum;

? ? rentNum+=temp.rentNum;

? ? total+=temp.money*temp.rentNum*temp.carNum;

? ? }

? ? System.out.println("累計:\t載客人數(shù):"+passNum+"人\t載貨噸位:"+goNum+"噸\t租車數(shù)量:"+carNum+"輛\t租車天數(shù):"+rentNum+"天\t租車金額:"+total+"元");

? ? rent();

}else{

System.out.println("您尚未選擇租賃車輛!請您選擇接下來的操作服務(wù)編號");

}

}

//選擇租賃車輛操作

public static void getRent(){

System.out.println("請輸入您想要租賃的車輛編號(1~6之間的整數(shù)),例如1代表[寶馬X1]");

int code = sc.nextInt();

try {

Car temp = clist.get(code-1);

System.out.println("請輸入您想要租賃 ["+temp.name+"]的數(shù)量:");

temp.carNum = sc.nextInt();

System.out.println("請輸入您想要租賃["+temp.name+"]的天數(shù):");

temp.rentNum = sc.nextInt();

rlist.add(temp);

System.out.println("["+temp.name+"]租賃完成!請您選擇接下來的操作服務(wù)編號");

rent();

} catch (Exception e) {

System.out.println("輸入有誤,請您重新運行程序!");

}

}

}


正在回答

0 回答

舉報

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

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

進(jìn)入課程

可以了,交作業(yè)

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

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

幫助反饋 APP下載

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

公眾號

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