Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Java to realize simple ordering system

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use Java to achieve a simple ordering system, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Program control analysis:

1. Welcome page loop: do-while

2. Scanner control input

3. Select a page loop: switch-case

Request:

Order information: String 2D array

Serial number, name, meal name, number, price, total price, address, time (10-20), status (booked, completed), heat (int)

Sign the order: change the status of the order, you can sign for it if it has been booked, and you can't sign for it again if it has been completed.

Delete order: the outstanding order cannot be deleted and the serial number should be changed accordingly.

I want to like: like the corresponding food and show it.

Package Practice;import java.util.Scanner;public class Obj {public static void main (String [] args) {Scanner sc=new Scanner (System.in); String dishes [] = {"braised pork", "roast bear's paw", "steamed fish", "white chopped chicken", "roast pigeon"}; int price [] = {58 minus 8pence 45pm 56pm 44}; int honors [] = {50mint 100pm 20pm 12pm 44}; int hot [] = {5pm 4pm 3pm 2O} String orders [] [] = new String [1024] []; int chose=0; System.out. Println ("Welcome Guanling Hong Romantic Restaurant"); do {System.out.println ("*"); / / display menu System.out.println ("1, I want to order"); System.out.println ("2, check the meal bag"); System.out.println ("3, sign for order") System.out.println ("4, delete order"); System.out.println ("5, I want to like"); System.out.println ("6, exit the system"); System.out.println ("*"); System.out.println ("Please select:"); chose=sc.nextInt () / / booking process-switch (chose) {case 1: System.out.println ("* I want to order a meal *") System.out.println ("Please enter the name of the person who ordered the meal:"); String name=sc.next (); System.out.println ("heat of the unit price of the serial number dish"); for (int I = 0; I < dishes.length) System.out.println (iTun1 + "\ t\ t" + dishes [I] + "\ t" + price [I] + "yuan\ t" + "\ t" + hot [I]);} int dishNum=0; do {System.out.println ("dish number") DishNum=sc.nextInt (); if ((dishNumdishes.length)) {System.out.println ("Sorry, there is a mistake, please re-enter it!") ;} while (dishNumdishes.length); int pcs=0; do {System.out.println ("number of copies"); pcs=sc.nextInt (); if (pcs0&&chose

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report