java实现简易外卖订餐系统
程序员文章站
2022-06-17 23:02:26
用java实现简易外卖订餐系统,供大家参考,具体内容如下一、使用技术javase二、实现功能外卖订餐系统具体要求如下:使用选择结构,循环结构,数组的知识实现一个外卖订餐系统三、运行效果图1.订餐功能2...
用java实现简易外卖订餐系统,供大家参考,具体内容如下
一、使用技术
javase
二、实现功能
外卖订餐系统
具体要求如下:
使用选择结构,循环结构,数组的知识实现一个外卖订餐系统
三、运行效果图
1.订餐功能
2.查看餐袋
3.签收订单
4.删除订单
5.点赞
6.退出
代码实现
public class order { public static void main(string[] args) { int zero = 1; int x = 0;//订单数组下标 string[] name = new string[100]; int[] time = new int[100];//点餐时间 string[] menu = new string[100]; double[] price = new double[100]; int[] od = new int[100];//订单序号 string[] adress = new string[100];//送餐地址 int[] menunum = new int[100];//点菜份数 string[] yuding = new string[100];//订单状态 int a = 0;//点赞数 int b = 0;//点赞数 int c = 0;//点赞数 int panduan = 0;//判断是否有此订单 scanner sc = new scanner(system.in); do { system.out.println("欢迎使用“外卖订餐系统”"); system.out.println("******************************"); system.out.println("1.我要订餐"); system.out.println("2.查看餐袋"); system.out.println("3.签收订单"); system.out.println("4.删除订单"); system.out.println("5.我要点赞"); system.out.println("6.退出系统"); system.out.println("******************************"); system.out.println("请选择:"); int num = sc.nextint(); while (num < 1 || num > 6) { system.out.println("您输入的选项没有,重新输入"); num = sc.nextint(); } if (num == 1) { od[x] = x + 1; yuding[x] = "已预订"; system.out.println("***我要订餐***"); system.out.println("请输入订餐人姓名:"); name[x] = sc.next(); system.out.println("序号" + " " + "菜名" + " " + "单价"); system.out.println(1 + " " + "红烧茄子" + " " + 24.00); system.out.println(2 + " " + "糖醋排骨" + " " + 36.00); system.out.println(3 + " " + "鱼香肉丝" + " " + 32.00); system.out.println("请选择您想要点的菜品编号:"); int bianhao = sc.nextint(); while (bianhao < 1 || bianhao > 3) { system.out.println("您选择的菜品没有,再次输入"); bianhao = sc.nextint(); } if (bianhao == 1) { menu[x] = "红烧茄子"; price[x] = 24.00; } else if (bianhao == 2) { menu[x] = "糖醋排骨"; price[x] = 36.00; } else if (bianhao == 3) { menu[x] = "鱼香肉丝"; price[x] = 32.00; } system.out.println("请选择您需要的份数:"); menunum[x] = sc.nextint(); while (menunum[x] < 1) { system.out.println("您输入的数量不合法,再次选择"); menunum[x] = sc.nextint(); } system.out.println("请选输入送餐时间(送餐时间是10点至20点间整点送餐):"); time[x] = sc.nextint(); while (time[x] < 10 || time[x] > 20) { system.out.println("您选择的时间不在送餐时间内,再次选择"); time[x] = sc.nextint(); } system.out.println("请输入送餐地址"); adress[x] = sc.next(); system.out.println("订餐成功!!!"); system.out.println("您订的是:" + menu[x] + " " + menunum[x] + "份"); system.out.println("送餐时间:" + time[x] + "点"); system.out.println("餐费:" + menunum[x] * price[x] + "元" + " " + "送餐费:6元" + " " + "总计:" + (menunum[x] * price[x] + 6) + "元"); system.out.println("输入0返回:"); zero = sc.nextint(); while (zero != 0) { system.out.println("输入错误,再次输入"); zero = sc.nextint(); } x++; } else if (num == 2) { zero = 1; system.out.println("***查看餐带***"); system.out.println("序号" + " " + "订餐人" + " " + "餐品信息" + " " + "送餐时间" + " " + "送餐地址" + " " + "总金额" + " " + "订单状态"); for (int i = 0; i < x; i++) { if (od[i] != -1) { system.out.println(od[i] + " " + name[i] + " " + menu[i] + " " + time[i] + " " + adress[i] + " " + (menunum[i] * price[i] + 6) + " " + yuding[i]); } } system.out.println("输入0返回:"); zero = sc.nextint(); while (zero != 0) { system.out.println("输入错误,再次输入"); zero = sc.nextint(); } } else if (num == 3) { zero = 1; system.out.println("***签收订单***"); system.out.println("请选择要签收的订单的序号:"); int numc = sc.nextint(); for (int i = 0; i < od.length; i++) { if (numc == od[i]) { yuding[i] = "已签收"; system.out.println("订单签收成功!"); panduan = 1; } } if (panduan != 1) { system.out.println("无此订单"); } system.out.println("输入0返回:"); zero = sc.nextint(); while (zero != 0) { system.out.println("输入错误,再次输入"); zero = sc.nextint(); } } else if (num == 4) { zero = 1; panduan = 0; system.out.println("***删除订单***"); system.out.println("请选择要删除的订单的序号:"); int numd = sc.nextint(); for (int i = 0; i < od.length; i++) { if (numd == od[i]) { od[i] = -1; system.out.println("订单删除成功!"); panduan = 1; } } if (panduan != 1) { system.out.println("无此订单"); } system.out.println("输入0返回:"); zero = sc.nextint(); while (zero != 0) { system.out.println("输入错误,再次输入"); zero = sc.nextint(); } } else if (num == 5) { zero = 1; system.out.println("***我要点赞***"); system.out.println("序号" + " " + "菜名" + " " + "单价"); system.out.println(1 + " " + "红烧茄子" + " " + 24.00 + " " + a + "赞"); system.out.println(2 + " " + "糖醋排骨" + " " + 36.00 + " " + b + "赞"); system.out.println(3 + " " + "鱼香肉丝" + " " + 32.00 + " " + c + "赞"); system.out.println("请选择要点赞的菜品的序号:"); int zan = sc.nextint(); while (zan < 1 || zan > 3) { system.out.println("您输入的序号错误,再次输入"); zan = sc.nextint(); } if (zan == 1) { a++; } else if (zan == 2) { b++; } else if (zan == 3) { c++; } system.out.println("输入0返回:"); zero = sc.nextint(); while (zero != 0) { system.out.println("输入错误,再次输入"); zero = sc.nextint(); } } else if (num == 6) { zero = 1; system.out.println("谢谢使用,欢迎下次光临!"); return; } } while (zero == 0); } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
上一篇: SecureCRT的使用超详细教程
下一篇: 用Python每天自动给女友免费发短信