继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

某次元的垃圾达达租车系统

qq_只是冬天饮雪水_0
关注TA
已关注
手记 2
粉丝 1
获赞 2

import java.util.Scanner;
class Demo
{
public static void main(String[] args)
{
Car[] c=new Car[6];
c[0]=new Car("小型载人",100,6,0);
c[1]=new Car("大型载人",600,48,0);
c[2]=new Car("小型载货",200,0,4);
c[3]=new Car("大型载货",800,0,20);
c[4]=new Car("小型载人载货",300,6,4);
c[5]=new Car("大型载人载货",1800,48,20);
JieMian jm=new JieMian();
Scanner input=new Scanner(System.in);

    jm.printZhuJieMian();

    if(input.nextInt()==1)
    {
        jm.printJiaGe(c);
    }else{return;}

    int numCarZhongLei=input.nextInt();

    int[] numCheXing=new int[numCarZhongLei];
    jm.printXuanChe();

    for (int i=0;i<numCarZhongLei;i++ )
    {
        numCheXing[i]=input.nextInt();
    }

    int[] numMeiZhongChe=new int[numCarZhongLei];
    jm.printCheShuLiang();
    for (int i=0;i<numCarZhongLei;i++ )
    {
        numMeiZhongChe[i]=input.nextInt();
    }

    int[] numTianShu=new int[numCarZhongLei];
    jm.printTianShu();
    for (int i=0;i<numCarZhongLei ;i++ )
    {
        numTianShu[i]=input.nextInt();
    }

    jm.jisuanjirguoJieMian(c,numCarZhongLei,numCheXing,numMeiZhongChe,numTianShu);

}

}
class Car
{
String CheXing;
int ZuJin;
int zr;
int zh;
Car(String CheXing,int ZuJin,int zr,int zh)
{
this.CheXing=CheXing;

    this.ZuJin=ZuJin;
    this.zr=zr;
    this.zh=zh;
}

}

class JieMian
{
void printZhuJieMian()
{
System.out.println("****");
System.out.println("*欢迎进入达达租车系统*****");
System.out.println(" **");
System.out.println("请问您是否进行租车业务**");
System.out.println("****");
System.out.println("*
进行租车业务请按1****");
System.out.println("*按其他任意键退出系统*");
System.out.println("***
");

}
void printJiaGe(Car[] c)
{
    System.out.println("*********************************");
    System.out.println("编号 车型       租金/天    载人量/辆 载货量/辆");
    for (int i=0;i<6 ;i++ )
    System.out.println(i+"  "+c[i].CheXing+"\t"+c[i].ZuJin+"\t"+c[i].zr+"\t"+"  "+c[i].zh);
    System.out.println("*********************************");
    System.out.println("你要选择几种车?:");
}
void printXuanChe()
{
    System.out.println("分别是什么车,用分别编号输入:");
}
void printCheShuLiang()
{
    System.out.println("请输入每种车的数量:");
}
void printTianShu()
{
    System.out.println("请输入租车的天数:");
}
void jisuanjirguoJieMian(Car[] c,int numCarZhongLei,int[] numCheXing,int[] numMeiZhongChe,int[] numTianShu)
{
    System.out.println("您的账单是:");   
    System.out.println("载人车是:");
    int sumZaiRen=0;int sumZaiHuo=0;int sumZaiRenZuJin=0;int sumZaiHuoZuJin=0;
    for (int i=0;i<numCarZhongLei ;i++ )
    {
        if (numCheXing[i]==0||numCheXing[i]==1||numCheXing[i]==4||numCheXing[i]==5)
        {
            sumZaiRen=sumZaiRen+c[numCheXing[i]].zr*numMeiZhongChe[i]*numTianShu[i];
            sumZaiRenZuJin=sumZaiRenZuJin+c[numCheXing[i]].ZuJin*numMeiZhongChe[i]*numTianShu[i];
            System.out.print("     ");
            System.out.print(c[numCheXing[i]].CheXing+"     ");
        }

    }
    System.out.print("总载人:"+sumZaiRen);

    System.out.println();
    System.out.println("载货车是:");
    for (int i=0;i<numCarZhongLei ;i++ )
    {
        if (numCheXing[i]==2||numCheXing[i]==3||numCheXing[i]==4||numCheXing[i]==5)
        {
            sumZaiHuo=sumZaiHuo+c[numCheXing[i]].zh*numMeiZhongChe[i]*numTianShu[i];
            sumZaiHuoZuJin=sumZaiHuoZuJin+c[numCheXing[i]].ZuJin*numMeiZhongChe[i]*numTianShu[i];
            System.out.print("     ");
            System.out.print(c[numCheXing[i]].CheXing+"     ");
        }

    }
    System.out.print("总载货:"+sumZaiHuo);
    System.out.println();

    System.out.println("总租金:"+(sumZaiRenZuJin+sumZaiHuoZuJin));

}

}

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP