In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces java how to achieve a simple takeaway ordering system, the text is very detailed, has a certain reference value, interested friends must read it!
I. Use of technology
javaSE
II. Fulfillment of functions
Takeaway ordering system
Specific requirements are as follows:
Use the knowledge of selection structure, loop structure and array to realize a takeaway ordering system
III. Operation effect diagram
1. Ordering function
2. View Bag
3. Sign an order
4. delete the order
5. Praise
6. exit
public class Order { public static void main(String[] args) { int zero = 1; int x = 0;//Order array subscript String[] name = new String[100]; int[] time = new int[100];//order time String[] menu = new String[100]; double[] price = new double[100]; int[] od = new int[100];//Order number String[] adress = new String[100];//Delivery address int[] menuNum = new int[100];//Number of dishes String[] yuDing = new String[100];//Order Status int a = 0;//number of likes int b = 0;//number of likes int c = 0;//number of likes int panduan = 0;//Determine if there is such an order Scanner sc = new Scanner(System.in); do { System.out.println("Welcome to the takeaway ordering system"); System.out.println("******************************"); System.out.println("1. I want to order"); System.out.println("2. View meal bag"); System.out.println("3. Sign order"); System.out.println("4. Delete Order"); System.out.println("5. I like"); System.out.println("6. Exit system"); System.out.println("******************************"); System.out.println("Please select: "); int num = sc.nextInt(); while (num
< 1 || num >6) { System.out.println("The option you entered is not available, re-enter"); num = sc.nextInt(); } if (num == 1) { od[x] = x + 1; yuDing[x] = "reserved"; System.out.println("*** I want to order **"); System.out.println("Please enter the name of the person ordering: "); name[x] = sc.next(); System.out.println("Sequence" + " " + " dish name " + " " + " unit price "); System.out.println(1 + " " + " braised eggplant " + " " + 24.00); System.out.println(2 + " " + " Sweet and sour ribs " + " " + 36.00); System.out.println(3 + " " + " Fish-flavored shredded pork " + " " + 32.00); System.out.println("Please select the dish number you want to order: "); int bianHao = sc.nextInt(); while (bianHao
< 1 || bianHao >3) { System.out.println("The dish you selected is not available, enter again"); bianHao = sc.nextInt(); } if (bianHao == 1) { menu[x] = "Braised eggplant"; price[x] = 24.00; } else if (bianHao == 2) { menu[x] = "Sweet and sour ribs"; price[x] = 36.00; } else if (bianHao == 3) { menu[x] = "Fish flavored shredded pork"; price[x] = 32.00; } System.out.println("Please select the number of copies you want: "); 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("The time you selected is not within the delivery time, select again"); time[x] = sc.nextInt(); } System.out.println("Please enter the delivery address"); adress[x] = sc.next(); System.out.println("Order successful!!! "); System.out.println("You ordered: " + menu[x] + " " + menuNum[x] + "copies"); System.out.println("Delivery time: " + time[x] + "point"); System.out.println("Meals: " + menuNum[x] * price[x] + "Yuan" + " " + "Meal delivery fee: 6 yuan" + " " + "Total: " + (menuNum[x] * price[x] + 6) + "yuan"); System.out.println("Enter 0 to return: "); zero = sc.nextInt(); while (zero != 0) { System.out.println("Input error, input again"); zero = sc.nextInt(); } x++; } else if (num == 2) { zero = 1; System.out.println("*** View meal belt ***"); System.out.println("Sequence" + " " + " Ordered by " + " " + " Meal information " + " " + " Delivery time " + " " + " Delivery address " + " " + " Total Amount " + " " + " Order Status "); 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("The serial number you entered is incorrect, enter it again"); zan = sc.nextInt(); } if (zan == 1) { a++; } else if (zan == 2) { b++; } else if (zan == 3) { c++; } System.out.println("Enter 0 to return: "); zero = sc.nextInt(); while (zero != 0) { System.out.println("Input error, input again"); zero = sc.nextInt(); } } else if (num == 6) { zero = 1; System.out.println("Thanks for using, welcome next time! "); return; } } while (zero == 0); }} The above is all the content of this article "Java how to implement a simple takeaway ordering system", thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.