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

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

Java入門(mén)第二季 答答租車(chē)系統(tǒng)

標(biāo)簽:
Java

父类:Car

package com.hxf;

public class Car {
public String carname;//车类
public double price;//单价价格
public int time;//租车时间
public int num;//车剩余多少量
public int cainum;//载客量
public double numkg;//载客量

public String getName(){
    return  carname;
}

public void setName(String carname){
    this.carname = carname;
}
public double getPrice(){
    return  price;
}

public void setPrice(double price){
    this.price = price;
}

public int getNum(){
    return  num;
}

public void setName(int num){
    this.num = num;
}

public double getNumKg(){
    return  numkg;
}

public void setNumKg(int numkg){
    this.numkg = numkg;
}

public int getCaiNum(){
    return  cainum;
}

public void setCaiNum(int cainum){
    this.cainum = cainum;
}
public void show(int i){//显示列车信息
     System.out.println(i+"\t"+this.carname+"\t"+this.price+"\t"+this.cainum+"\t"+this.numkg+"\t"+this.num);
}

}
只载人的车类:PassengerCar
package com.hxf;

public class PassengerCar extends Car {

public PassengerCar(String carname, int num, double price,int cainum ) {
    this.carname = carname;
    this.price = price;
    this.num = num;
    this.cainum = cainum;
}

}
只载物车的类:Truck
package com.hxf;

public class Truck extends Car {

public Truck(String carname, int num, double price,double numkg) {
    this.carname = carname;
    this.price = price;
    this.num = num;
    this.numkg = numkg;
}

}
载物又载人的车类:Pickup
package com.hxf;

public class Pickup extends Car {

public Pickup(String carname, int num, double price,int cainum ,double numkg) {
    this.carname = carname;
    this.price = price;
    this.num = num;
    this.cainum = cainum;
    this.numkg = numkg;
}

}
接口:Test
package com.hxf;
import java.util.Scanner;
public class Test {
public int zcnum; //租车天数
public double total;//租车总金额
public double totalkg;//租车总载物量
public int totalnum;//租车总载人量
public static void main(String[] args) {
Test test = new Test();
if(test.head() == 1){
Car[] cars = {new PassengerCar("宝马", 5, 500, 5),new PassengerCar("宝马1", 6, 650, 1),new Pickup("皮卡2",2, 600, 1,2) ,new Pickup("皮卡1",2, 500, 3,2.3) ,new Truck("依维河",3, 1000,12.3),new Truck("依维河2",2, 800,5)};
System.out.println("现在还有"+cars.length+"辆车可以租");
System.out.println("您可租车的类型及其价目表");
System.out.println("序号"+"\t"+"汽车名称"+"\t"+"租金(天)"+"\t"+"载客量(个)"+"\t载货量(吨)"+"\t剩余数量");
int i=0;
for(Car car1:cars){
++i;
car1.show(i); //显示可以租车列表
}
test.zcnum = test.XuanZhe(cars.length);//租车数量
double[][] data = new double[test.zcnum][4];//保存租车的价格、时间、载物量、载客量
String[] dataname = new String[test.zcnum];//保存租车的汽车名
for(int j=0;j<test.zcnum;j++){
Scanner input = new Scanner(System.in);
System.out.println("请输入车辆序号:");
int id = input.nextInt();
System.out.println("请输租车天数:");
int id1 = input.nextInt();
data[j][0] = cars[id-1].getPrice()*id1;
data[j][1] = cars[id-1].getCaiNum();
data[j][2] = cars[id-1].getNumKg();
data[j][3] = (double)id1;
dataname[j] = cars[id-1].getName();
test.total += data[j][0]; //计算租车的总价
test.totalkg += data[j][2]; //计算租车的总载物量
test.totalnum += data[j][1];//计算租车的总载客量

        }
        System.out.println("详细账单如下");
        test.Xxshow(data,dataname);//显示详细账单

    }else{
        System.out.println("欢迎下次使用答答租车系统!");
    }

}

public int head(){
    System.out.println("欢迎使用答答租车系统!");
    System.out.println("您是否需要租车:1是 0否");
    Scanner input = new Scanner(System.in);
    int is = input.nextInt(); 
    if(is ==1){
        return 1;
    }else{
        return 0;
    }
}

public int  XuanZhe(int i){
    Scanner input = new Scanner(System.in);
    System.out.print("请输入你租车数量:");
    int zcnum1 = input.nextInt(); 
    if(zcnum1>i){
        System.out.print("抱歉!现在没有这么多辆车,请重新输入");
        return this.XuanZhe(i);//递归
    }

    return zcnum1;

}

public void Xxshow(double[][] data,String[] data2){
    int num = data.length;
    System.out.println("序号"+"\t"+"汽车名称"+"\t"+"金额"+"\t"+"载客量(个)"+"\t载货量(吨)"+"\t租车时间(天)");
    for(int i=0;i<num;i++){
        System.out.println((i+1)+"\t"+data2[i]+"\t"+data[i][0]+"\t"+data[i][1]+"\t"+data[i][2]+"\t"+(int)data[i][3]);
    }
    System.out.println("\n");
    System.out.println("租车总金额为:"+this.total+"\t租车总载货量:"+this.totalkg+"\t租车总载客量:"+this.totalnum);
}

}

测试结果
欢迎使用答答租车系统!
您是否需要租车:1是 0否

1
现在还有6辆车可以租
您可租车的类型及其价目表
序号 汽车名称 租金(天) 载客量(个) 载货量(吨) 剩余数量
1 宝马 500.0 5 0.0 5
2 宝马1 650.0 1 0.0 6
3 皮卡2 600.0 1 2.0 2
4 皮卡1 500.0 3 2.3 2
5 依维河 1000.0 0 12.3 3
6 依维河2 800.0 0 5.0 2
请输入你租车数量:7
抱歉!现在没有这么多辆车,请重新输入请输入你租车数量:1
请输入车辆序号:
6
请输租车天数:
6
详细账单如下
序号 汽车名称 金额 载客量(个) 载货量(吨) 租车时间(天)
1 依维河2 4800.0 0.0 5.0 6

租车总金额为:4800.0 租车总载货量:5.0 租车总载客量:0

欢迎使用答答租车系统!
您是否需要租车:1是 0否

1
现在还有6辆车可以租
您可租车的类型及其价目表
序号 汽车名称 租金(天) 载客量(个) 载货量(吨) 剩余数量
1 宝马 500.0 5 0.0 5
2 宝马1 650.0 1 0.0 6
3 皮卡2 600.0 1 2.0 2
4 皮卡1 500.0 3 2.3 2
5 依维河 1000.0 0 12.3 3
6 依维河2 800.0 0 5.0 2
请输入你租车数量:4
请输入车辆序号:
1
请输租车天数:
1
请输入车辆序号:
2
请输租车天数:
2
请输入车辆序号:
3
请输租车天数:
3
请输入车辆序号:
5
请输租车天数:
5
详细账单如下
序号 汽车名称 金额 载客量(个) 载货量(吨) 租车时间(天)
1 宝马 500.0 5.0 0.0 1
2 宝马1 1300.0 1.0 0.0 2
3 皮卡2 1800.0 1.0 2.0 3
4 依维河 5000.0 0.0 12.3 5

租车总金额为:8600.0 租车总载货量:14.3 租车总载客量:7

點(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)專(zhuān)欄免費(fèi)學(xué)

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

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

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

幫助反饋 APP下載

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

公眾號(hào)

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

舉報(bào)

0/150
提交
取消