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

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

Java第二季答答租車系統(tǒng)

標(biāo)簽:
Java
package ddrentcar;

public class Car {
private String carName;//车辆的名称
private double price;//租用价格
private int busLoad;//载客量
private double cargo;//载货量
public String getCarName(){
    return carName;
}
public void setCarName(String carName){
    this.carName=carName;
}
public double getPrice(){
    return price;
}
public void setPrice(double price){
    this.price=price;
}
public int getBusLoad(){
    return busLoad;
}
public void setBusLoad(int busLoad){
    this.busLoad=busLoad;
}
public double getCargo(){
    return cargo;
}
public void setCargo(double cargo){
    this.cargo=cargo;
}
}
package ddrentcar;

public class Passengercar extends Car {
public Passengercar(String carName,double price,int busLoad,double cargo){
    this.setCarName(carName);
    this.setPrice(price);
    this.setBusLoad(busLoad);
    this.setCargo(cargo);
}
}
package ddrentcar;

public class Trunk extends Car {
public Trunk(String carName,double price,int busLoad,double cargo){
    this.setCarName(carName);
    this.setPrice(price);
    this.setBusLoad(busLoad);
    this.setCargo(cargo);
}
}

package ddrentcar;

public class Pickup extends Car {
public Pickup(String carName,double price,int busLoad,double cargo){
    this.setCarName(carName);
    this.setPrice(price);
    this.setBusLoad(busLoad);
    this.setCargo(cargo);
}
}

package ddrentcar;
import java.util.Scanner;
public class Initial {
    private static Scanner input=new Scanner(System.in);
    public static void main(String[] args) {
        // TODO Auto-generated method stub
Car[] carForRent={new Passengercar("奥迪A4",500,4,0),new Passengercar("马自达6",400,4,0),new Pickup("皮卡雪6",450,4,2),new Passengercar("金龙",800,20,0),new Trunk("依维柯",1000,0,20),new Trunk("松花江",400,0,4)};

while(true){
    System.out.println("欢迎使用答答租车系统:您是否需要租车:1是 0否");
    try{
        int choose=inputCommand();
        switch(choose){
        case 1:
            System.out.println("您可租车类型及价目表"); 
        System.out.println("序号"+"\t"+"汽车名称"+"\t"+"租金"+"\t"+"载客量"+"\t"+"载货量");
        for(int i=0;i<carForRent.length;i++){
            System.out.println((i+1)+"\t"+carForRent[i].getCarName()+"\t"+carForRent[i].getPrice()+"\t"+carForRent[i].getBusLoad()+"\t"+carForRent[i].getCargo());
        }
        System.out.println("请输入您需要租车的数量:");
        //Scanner input2=new Scanner(System.in);
        int carNum=input.nextInt();//租车数量
        double[] eachKindPrice=new double[6];//所租用的每种类型车的单日总租金
        for(int i=0;i<carForRent.length;i++){
            System.out.println("请依次输入您所需的第"+(i+1)+"号车数量");
        //Scanner input3=new Scanner(System.in);
        int num=input.nextInt();
        eachKindPrice[i]=num*carForRent[i].getPrice();
        }
        System.out.println("请输入租车天数:");
        //Scanner input4=new Scanner(System.in);
        int days=input.nextInt();
        double[] dailyPrice=new double[6];//单日总租金
        double totalPrice=0;//总租金
        System.out.println("您的账单为:");
        for(int i=0;i<6;i++){
            dailyPrice[i]=days*eachKindPrice[i];
            System.out.println("租第"+(i+1)+"号车的费用为:"+dailyPrice[i]+"元");
        totalPrice+=dailyPrice[i];
        }
        System.out.println("总租金为:"+totalPrice+"元");
            break;
        case 0:
            System.out.println("感谢你的访问");
            break;
        case -1:
            System.out.println("输入错误,请按照提示输入");
            continue;
        default:
            System.out.println("输入错误,请按照提示输入");
            continue;
        }break;

    }catch(Exception ss){
        System.out.println(ss.getMessage());
        continue;
    }
}

 }
    private static int inputCommand(){
        try{
        int command=input.nextInt();
        return command;
        }catch(Exception e){
            input=new Scanner(System.in);
            return -1;
        }
    }
}
點(diǎn)擊查看更多內(nèi)容
1人點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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

舉報(bào)

0/150
提交
取消