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

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

福爾摩灰_Java入門(mén)第二季_租車系統(tǒng)

標(biāo)簽:
Java
public abstract class Car {
    public String name;
    public int price;
    public void pr(){
        System.out.println(name + "\t" + price + "元/天\t");
    }
}
public class PeopleCar extends Car {
    public int people ;
    @Override
    public void pr() {
        // TODO 自动生成的方法存根
        System.out.println(name + "\t" + price + "\t载人量:" + people +"人");
    }

    public PeopleCar(String s,int a,int b)
    {
        this.name = s;
        this.price = a;
        this.people = b;
        }
}
public class PickUp extends Car {
    public int people ;
    public int goods;
    @Override
    public void pr() {
        // TODO 自动生成的方法存根
        System.out.println(name + "\t" + price + "\t载人量:" + people  +"人" +",载货量:"+goods +"吨");
    }
    public PickUp(String a,int b,int c,int d) {
        // TODO 自动生成的构造函数存根

        this.name = a;
        this.price = b;
        this.people = c;
        this.goods = d;
    }

}
public class Truck extends Car {
    public int goods;//载货量
    @Override
    public void pr() {
        // TODO 自动生成的方法存根
        System.out.println(name + "\t" + price + "\t载货量:" + goods +"吨");
    }
    public Truck(String s,int a,int b)
    {
        this.name = s;
        this.price = a;
        this.goods = b;
    }
}
import java.util.Scanner;

public class Test {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        Test test = new Test();
        Car[] car={
            new PeopleCar("奥迪A4",500,4),
            new PeopleCar("马自达6", 400,4),
            new PickUp("皮卡雪6", 450, 4, 2),
            new PeopleCar("金龙", 800, 20),
            new Truck("松花江", 400, 4),
            new Truck("依维柯", 1000, 20),
        };
        int weather;
        int number,a;
        int day;
        int sum = 0;
        Scanner input = new Scanner(System.in);
        System.out.println("是否租车?1.是  0.不是");
        weather = input.nextInt();
        if(weather == 1)
        {
            System.out.println("可租的汽车类型及价格表");
            System.out.println("序号\t汽车名称\t租金\t容量\t");
            for(int i = 0;i<6;i++)
            {
                System.out.print( (i+1) + "\t" );
                car[i].pr();
            }
            System.out.println("请输入您要租的车辆数:");
            number = input.nextInt();
            for(int i = 0; i<number; i++)
            {
                System.out.println("请输入要选的车的序号:");
                a=input.nextInt();
                sum += car[a-1].price;
            }
            System.out.println("请输入租车天数:");
            day = input.nextInt();
            System.out.println("总的租金为:" + day*sum +"元");
        }
        else{System.out.println("退出租车系统");}
    }
}
點(diǎn)擊查看更多內(nèi)容
2人點(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
提交
取消