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

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

java第二季綜合練習(xí),答答租車(chē)系統(tǒng)

標(biāo)簽:
Java

package com.dada;
//Vehicle父类
public abstract class Vehicle {
String name;
int pernum;
int weight;
int rent;

public abstract void method();

}

package com.dada;
//载货Truck类
public class Truck extends Vehicle{

public void method(){
System.out.println(name+'\t'+rent+"/天\t"+"载重:"+weight+"吨");
}
}

package com.dada;
//载客Car类
public class Car extends Vehicle {
public void method(){
System.out.println(name+'\t'+rent+"/天\t"+"载人:"+pernum+"人");
}
}

package com.dada;
//载货载客Other类
public class Other extends Vehicle{
public void method(){
System.out.println(name+'\t'+rent+"/天\t"+"载人:"+pernum+"人"+"载重:"+weight+"吨");
}
}

package com.dada;

import java.util.Scanner;
//Initial测试类
public class Initial {

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub
    Vehicle car1=new Car();
    Vehicle car2=new Car();
    Vehicle car3=new Car();
    Vehicle truck1=new Truck();
    Vehicle truck2=new Truck();
    Vehicle other=new Other();
    car1.name="奥迪A4";
    car1.pernum=4;
    car1.rent=500;
    car2.name="马自达6";
    car2.pernum=4;
    car2.rent=400;
    car3.name="金龙";
    car3.pernum=20;
    car3.rent=800;
    truck1.name="松花江";
    truck1.weight=4;
    truck1.rent=400;
    truck2.name="依维柯";
    truck2.weight=20;
    truck2.rent=1000;
    other.name="皮卡雪6";
    other.pernum=4;
    other.weight=2;
    other.rent=450;

    System.out.println("欢迎使用租车系统:\n您是否要租车:1 是 0否");
    Scanner input=new Scanner(System.in);
    int p=input.nextInt();
    if(p==1){
        System.out.println("您可租车的类型及价目表:\n序号\t汽车名称\t租金 \t容量");
        System.out.print("1\t");car1.method();
        System.out.print("2\t");car2.method();
        System.out.print("3\t");car3.method();
        System.out.print("4\t");other.method();
        System.out.print("5\t");truck1.method();
        System.out.print("6\t");truck2.method();
    }else{
        System.exit(0);
    }
    System.out.println("请输入您要租车的数量:");
    int carNum=input.nextInt();
    int a=0,b=0,c=0,d=0,e=0,f=0;
    for(int i=1;i<=carNum;i++){
        System.out.println("请输入第"+i+"量车的序号:");
        int N=input.nextInt();
        if(N==1){
            a=a+1;
        }
        if(N==2){
            b=b+1;
        }
        if(N==3){
            c=c+1;
        }
        if(N==4){
            d=d+1;
        }
        if(N==5){
            e=e+1;
        }
        if(N==6){
            f=f+1;
        }
    }

    int totalPerNum=car1.pernum*a+car2.pernum*b+car3.pernum*c+other.pernum*d;
    int totalWeight=other.weight*d+truck1.weight*e+truck2.weight*f;
    int totalRent=car1.rent*a+car2.rent*b+car3.rent*c+other.rent*d+truck1.rent*e+truck2.rent*f;

    System.out.println("请输入您要租车的天数:");
    int dayNum=input.nextInt(); 
    System.out.println("您的账单:");
    System.out.println("***可载人的车有:");
    if(a!=0){
        System.out.print(car1.name+'\t');
    }
    if(b!=0){
        System.out.print(car2.name+'\t');
    }
    if(c!=0){
        System.out.print(car3.name+'\t');
    }
    if(d!=0){
        System.out.print(other.name+'\t');
    }
    System.out.println("共载人:"+totalPerNum+"人");
    System.out.println("***可载货的车有:");
    if(d!=0){
        System.out.print(other.name+'\t');
    }
    if(e!=0){
        System.out.print(truck1.name+'\t');
    }
    if(f!=0){
        System.out.print(truck2.name+'\t');
    }
    System.out.println("共载货:"+totalWeight+"吨");
    System.out.println("总租金:"+totalRent*dayNum+"元");

}

}

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