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

**记录下第一次敲代码**课程《JAVA入门第二季》项目实战 达达租车系统

标签:
Java
package com.imooc;
import java.util.Scanner;
public class Test {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
         Aodi aodi=new Aodi();
         Mazida mazida=new Mazida();
         Pikaxue pikaxue=new Pikaxue();
         Jinlong jinlong=new Jinlong();
         Songhuajiang songhuajiang=new Songhuajiang();
         Yiweike yiweike=new Yiweike();

        System.out.println("欢迎使用达达租车系统:");
        System.out.println("您是否要租车:1 是  2 否");
        Scanner input=new Scanner(System.in);
        int answer=input.nextInt();
        if (answer==1){
            System.out.println("序号\t"+"汽车名称\t"+"租金\t\t"+"容量\t\t\t"); 
            System.out.println(aodi.num+"."+"\t"+aodi.name+"\t"+aodi.money+"元/每天"+"\t"+"载人:"+aodi.peopleMount+"人");
            System.out.println(mazida.num+"."+"\t"+mazida.name+"\t"+mazida.money+"元/每天"+"\t"+"载人"+mazida.peopleMount+"人");
            System.out.println(pikaxue.num+"."+"\t"+pikaxue.name+"\t"+pikaxue.money+"元/每天"+"\t"+"载人"+pikaxue.peopleMount+"人"+"\t"+"载重:"+pikaxue.goodsMount+"吨");
            System.out.println(jinlong.num+"."+"\t"+jinlong.name+"\t"+jinlong.money+"元/每天"+"\t"+"载人:"+jinlong.peopleMount+"人");
            System.out.println(songhuajiang.num+"."+"\t"+songhuajiang.name+"\t"+songhuajiang.money+"元/每天"+"\t"+"载重:"+songhuajiang.goodsMount+"吨");
            System.out.println(yiweike.num+"."+"\t"+yiweike.name+"\t"+yiweike.money+"元/每天"+"\t"+"载重:"+yiweike.goodsMount+"吨");
        }
         System.out.println("请输入您要租汽车的数量:");
         Scanner input2=new Scanner(System.in);
         int count=input2.nextInt();
         int totalCount=0;
         int totalprice=0;
         int totalload=0;
         String a = null;
         String b = null;
         for(int i=1;i<=count;i++){
             System.out.println("请输入第"+i+"辆车的序号:");
             Scanner input3=new Scanner(System.in);
             int carCount=input3.nextInt();
             if(carCount==aodi.num){
                 totalCount=totalCount+aodi.peopleMount;
                 totalprice=totalprice+aodi.money;
                 a=aodi.name;
             }else if(carCount==mazida.num){
                 totalCount=totalCount+mazida.peopleMount;  
                 totalprice=totalprice+mazida.money;
                 a=a+"\t"+mazida.name;
             }else if(carCount==pikaxue.num){
                 totalCount=totalCount+pikaxue.peopleMount;
                 totalprice=totalprice+pikaxue.money;
                 totalload=totalload+pikaxue.goodsMount;
                 a=a+"\t"+pikaxue.name;
                 b=b+"\t"+pikaxue.name;
             }else if(carCount==jinlong.num){
                 totalCount=totalCount+jinlong.peopleMount; 
                 totalprice=totalprice+jinlong.money;
                 a=a+"\t"+jinlong.name;
             }else if(carCount==songhuajiang.num){
                 totalprice=totalprice+songhuajiang.money;
                 totalload=totalload+songhuajiang.Goodsmonut;   
                 a=a+"\t"+songhuajiang.name;
                 b=b+"\t"+songhuajiang.name;
             }else if(carCount==yiweike.num){
                 totalprice=totalprice+yiweike.money;
                 totalload=totalload+yiweike.Goodsmonut;
                 a=a+"\t"+yiweike.name;
                 b=b+"\t"+yiweike.name;
             }
            }
         System.out.println("请输入租车天数:");
         Scanner input4=new Scanner(System.in);
          int carDay=input.nextInt();
          System.out.println("您的账单:");
          System.out.println("可载人的车有:"+a+"\t共载人:"+totalCount+"人");
          System.out.println("可载货的车有:"+b+"\t共载货:"+totalload+"吨");
         System.out.println("**租车总价格"+totalprice*carDay+"元"); 
    }
}

运行结果:
图片描述

点击查看更多内容
TA 点赞

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

评论

作者其他优质文章

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

100积分直接送

付费专栏免费学

大额优惠券免费领

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

举报

0/150
提交
取消