最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

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

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

標(biāo)簽:
Java

/
车类Car
*/

public abstract class Car {
public String name;
public int personCapacity;//载客量
public int goodCapacity;//载货量
public int price;//租车价格

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public abstract void printInfo();

}
//客车类
public class Coach extends Car {

public Coach(String name,int price,int personCapacity){
this.name=name;
this.personCapacity=personCapacity;
this.price=price;
}

public void printInfo(){
System.out.println(this.name+"\t"+this.price
+"元/天\t载客:"+this.personCapacity+"人");
}
//货车
public class Truck extends Car {

public final int personCapacity=0;//货车载客量为0

public Truck(String name,int price,int goodCapacity){
    this.name=name;
    this.price=price;
    this.goodCapacity=goodCapacity;
}

public void printInfo(){
    System.out.println(this.name+"\t"+this.price
             +"元/天\t载货:"+this.goodCapacity+"吨");
}

}
//皮卡,既能载客又能载货
public class Pk extends Car {

public Pk(String name,int price,int personCapacity,int goodCapacity){
    this.name=name;
    this.price=price;
    this.personCapacity=personCapacity;
    this.goodCapacity=goodCapacity;
}

public void printInfo(){
    System.out.println(this.name+"\t"+this.price
             +"元/天\t载客:"+this.personCapacity+"人\t载货:"+this.goodCapacity+"吨");
}

}

import java.util.Scanner;
public class Initial {

/**
 * @param args
 */
public static void main(String[] args) {

 Car[] cars={new Coach("奥迪",500,4),new Coach("马自达6",400,4)
            ,new Coach("金龙",800,20),new Pk("皮卡雪6",450,4,2)
            ,new Truck("松花江",400,4),new Truck("依维柯",1000,20)};

    Scanner sc=new Scanner(System.in);
    System.out.println("欢迎使用答答租车系统");
    System.out.println("您是否要租车?0:不是,1:是");
    int i=sc.nextInt();
    switch(i){
    case 0:{
        System.out.println("您已退出该系统");
        break;
    }
    case 1:{
        System.out.println("您可租车的车型及其价目表如下:");
        System.out.println("序号\t汽车名称\t租金\t容量");
         for(int j=0;j<cars.length;j++){
             System.out.print(j+1+"\t");
             cars[j].printInfo();
         }

        System.out.println("请输入您要租车的数量:");
        int number=sc.nextInt();

        System.out.println("奥迪的数量:");
        int number1=sc.nextInt();

        System.out.println("马自达6的数量:");
        int number2=sc.nextInt();

        System.out.println("金龙的数量:");
        int number3=sc.nextInt();

        System.out.println("皮卡雪6的数量:");
        int number4=sc.nextInt();

        System.out.println("松花江的数量:");
        int number5=sc.nextInt();

        System.out.println("依维柯的数量:");
        int number6=sc.nextInt();

        System.out.println("请输入您要租车的天数:");
        int day=sc.nextInt();
        System.out.println("您租车的金额为:"
        +(cars[0].price*number1+cars[1].price*number2
                +cars[2].price*number3+cars[3].price*number4+
                cars[4].price*number5+cars[5].price*number6)*day+"元");

        break;
    }

}

}
}

點(diǎn)擊查看更多內(nèi)容
5人點(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
提交
取消