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

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

Java入門(mén)第二季,鄙人解答,獻(xiàn)丑了

標(biāo)簽:
Java

主程序

import java.util.Scanner;
/**
 * Created by romanten on 2017/11/4.
 */
public class Login {
    public static void main(String[] args) {
        System.out.println("欢迎使用哒哒租车系统!");
        System.out.println("请问您是否要租车:1是 0否");
        Scanner input = new Scanner(System.in);
        int isHire = input.nextInt();
        if (isHire==0) {
            System.out.println("好吧,欢迎再来!");
            System.exit(0);
        }else{
            System.out.println("您可租车的类型及其价目表:");
            System.out.println("序号\t汽车名称\t租金\t容量");
            Car[] forHire={new Bus("奥迪A4",500,4),
                    new Bus("马自达",400,4),
                    new PickUp("皮卡雪",450,4,2),
                    new Bus("金龙",800,20),
                    new Truck("松花江",400,4),
                    new Truck("依维柯",1000,20)};
            int i=1;
            for(Car current:forHire){ //foreach
                if(current instanceof Bus){
                    System.out.print(i++);
                    current.print_name();
                    current.print_rent();
                    System.out.println("载人量(人):"+((Bus)current).getManCapacity());
                }
                else if(current instanceof Truck){
                    System.out.print(i++);
                    current.print_name();
                    current.print_rent();
                    System.out.println("载货量(吨):"+((Truck)current).getLoadCapacity());
                }else{
                    System.out.print(i++);
                    current.print_name();
                    current.print_rent();
                    System.out.println("载人(人)"+((PickUp)current).getManCapacity()+
                            " 载货(吨):"+((PickUp)current).getLoadCapacity());
                }
            }
            System.out.print("请输入您要租车的数量:");
            int count=input.nextInt();
            int[] rentCar=new int[count];
            double sum_rent=0;
            double sum_man=0;
            double sum_load=0;
            for(i=count;i>0;i--){
                System.out.println("请输入第"+(count-i+1)+"辆车的序号:");
                rentCar[count-i]=input.nextInt();
            }
            System.out.println("请输入租车天数:");
            int rentDay=input.nextInt();
            System.out.println("您的账单:\n***可载人的车有:");
            for(i=0;i<count;i++){
                if((forHire[(rentCar[i]-1)] instanceof Bus)) {
                    forHire[(rentCar[i]-1)].print_name();
                    sum_man+=((Bus)forHire[(rentCar[i]-1)]).getManCapacity();
                    sum_rent+=((Bus)forHire[(rentCar[i]-1)]).rent;
                }
                if((forHire[(rentCar[i]-1)] instanceof PickUp)) {
                    forHire[(rentCar[i]-1)].print_name();
                    sum_man+=((PickUp)forHire[(rentCar[i]-1)]).getManCapacity();
                    sum_rent+=((PickUp)forHire[(rentCar[i]-1)]).rent;
                }
            }
            System.out.println("共载人:"+sum_man+"人");
            System.out.println("***可载货的车有:");
            for(i=0;i<count;i++){
                if((forHire[(rentCar[i]-1)] instanceof Truck)) {
                    forHire[(rentCar[i]-1)].print_name();
                    sum_load+=((Truck)forHire[(rentCar[i]-1)]).getLoadCapacity();
                    sum_rent+=((Truck)forHire[(rentCar[i]-1)]).rent;
                }
                if((forHire[(rentCar[i]-1)] instanceof PickUp)) {
                    forHire[(rentCar[i]-1)].print_name();
                    sum_load+=((PickUp)forHire[(rentCar[i]-1)]).getLoadCapacity();
                    //sum_rent+=((PickUp)forHire[(rentCar[i]-1)]).rent;
                    //皮卡即载货又载人。但是价格只算一次
                }
            }
            System.out.println("共载货:"+sum_load+"吨");
            System.out.println("***总价格:"+(sum_rent*rentDay)+"元");
        }
    }
}
點(diǎn)擊查看更多內(nèi)容
4人點(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
提交
取消