为了账号安全,请及时绑定邮箱和手机立即绑定

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

标签:
Java

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));

}

}

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消