当前位置: 首页 > news >正文

汽车租赁系统1.0版本

汽车租赁系统1.0版本比较简陋,以后还会有2.0、3.0……就像《我爱发明》里面的一代机器二代机器,三代机器一样,是一个迭代更新的过程(最近比较忙,可能会很久),这个1.0版本很简陋,也请大家提提意见。

 

下面是代码区:

首先是文件Car.java

package Car;public class Car {String brand;String type;String vehicleid;int rent;public Car() {// 默认构造函数}public Car(String tempbrand, String temptype, String tempvehicleid, int temprent) {brand = tempbrand;type = temptype;vehicleid = tempvehicleid;rent = temprent;}public double getTotalRent(int tempday) {if (tempday <= 7)return tempday * rent;else if (tempday > 7 && tempday <= 30)return tempday * rent * 0.9;else if (tempday > 30 && tempday <= 150)return tempday * rent * 0.8;elsereturn tempday * rent * 0.7;}
}

然后是 文件Main.java

 我简单弄了个while循环,如果你输入了系统里面没有的型号或者输错了,它会一直提醒你重新输入,直到你正确输入,然后输入租车天数才会退出。

package Car;import java.util.Scanner;
public class Main {public static void main(String[] args) {// 数组初始化Car[] cars = new Car[4]; // 假设我们需要四个元素cars[0] = new Car("长安", "X", "京CNY3284", 800);cars[1] = new Car("长安", "Y", "京NY28588", 300);cars[2] = new Car("吉利", "G", "京NT37465",300);cars[3] = new Car("吉利", "H", "京NT96968",500);// 示例:计算一个车的总租金System.out.println("请输入你想租车的型号");Scanner sc = new Scanner(System.in);while (true){String type = sc.next();int index=-1;for(int i=0;i<cars.length;i++) {if(cars[i].type.equals(type))index = i;}if(index<0) {System.out.println("对不起,没有您想要的型号");System.out.println("请重新输入:");}else{System.out.println("请输入你想租车的天数:");int days = sc.nextInt();System.out.println("该型号租金单价" + cars[index].rent + "元/天");double totalRent = cars[index].getTotalRent(days);System.out.println("您共需支付租金:" + totalRent + "元");break;}}}
}

http://www.lryc.cn/news/438511.html

相关文章:

  • DockerDocker Compose安装(离线+在线)
  • 【泰克生物】酵母展示建库技术解析:构建高质量抗体文库的实用指南
  • QT Mode/View之View
  • URP 线性空间 ui资源制作规范
  • 如何精确统计Pytorch模型推理时间
  • Mybatis-plus-Generator 3.5.5 自定义模板支持 (DTO/VO 等) 配置
  • C#环境下MAC地址获取方法解析
  • (k8s)Kubernetes 从0到1容器编排之旅
  • Rust Web开发框架对比:Warp与Actix-web
  • F12抓包12:Performance(性能)前端性能分析
  • 数据结构(Day13)
  • 链表的快速排序(C/C++实现)
  • css总结(记录一下...)
  • SpringBoot 处理 @KafkaListener 消息
  • Spring Boot-API版本控制问题
  • Git 提取和拉取的区别在哪
  • 【数据结构与算法 | 每日一题 | 力扣篇】力扣2390, 2848
  • 破解信息架构实施的密码:常见挑战与最佳解决方案全指南
  • CodeChef Starters 151 (Div.2) A~D
  • Redis学习——数据不一致怎么办?更新缓存失败了又怎么办?
  • 跨境电商代购新纪元:一键解锁全球好物,系统流程全揭秘
  • Mac 上终端使用 MySql 记录
  • 461. 汉明距离
  • 开发指南061-nexus权限管理
  • Qt 弹出菜单右键菜单 QMenu 设置不同颜色的子项
  • Git换行符自动转换参数core.autocrlf的用法
  • C语言的结构体类型
  • illustrator 收集字体插件VBscript
  • 【LLM多模态】文生视频评测基准VBench
  • 通过覆写 url_for 将 flask 应用部署到子目录下