Simple "Order System" (for Beginners) with basic Java knowledge

Source: Internet
Author: User

Import Java.util.Scanner;
public class Orderingmsg {
public static void Main (string[] args) throws Exception {
Scanner Scanner = new Scanner (system.in);
string[] names = new String[6]; Name of the person who ordered the meal
string[] Dishmsgs = new string[6];//Selection Menu
int[] numbers = new int[6];//portion of dishes
Int[] times = new Int[6]; Meal Delivery Time
String[] Addresses = new string[6];//delivery address
Int[] states = new int[6];//order status 0: Already scheduled 1: Completed
double[] Sumprices = new double[6];//Total amount
int[] praisenums = new Int[6];
String[] Dishnames = {"Beijing roast Duck", "mapo tofu", "Squirrel fish", "braised octopus", "seasonal vegetables", "Spicy potato silk"};
double[] Prices = {88, 24, 38, 35, 15, 12};
System.out.println ("Welcome to Surper ordering System");
int num =-1; Enter 0 to return to the main menu by default
Boolean isexit = false;//does not exit by default
do {
System.out.println ("**********************");
System.out.println ("1: I want to order a meal");
System.out.println ("2: View Meal bag");
System.out.println ("3: Sign Order");
System.out.println ("4: Delete order");
System.out.println ("5: I Want to praise");
System.out.println ("6: Exit system");
System.out.println ("**********************");
SYSTEM.OUT.PRINTLN ("Please select:");
int choice = Scanner.nextint (); Choose the services you need
Switch (choice) {
Case 1:
System.out.println ("************ I want to order a meal ************");
Boolean empty = false;//as a token
for (int i = 0; i < names.length; i++) {//Set of meals
if (names[i] = = null) {
Empty = true;//Order if it is blank, you can go to Riga data
System.out.println ("Please enter the name of the person who ordered the meal:");
Names[i] = Scanner.next (); Get the name of the person who ordered the meal
System.out.println ("You can choose the following dishes:");
System.out.println ("ordinal \t\t\t dish name \t\t\t price \t\t\t number of likes");
for (int j = 0; J < Dishnames.length; J + +) {//Traversal of menu items
String Praisenum = (Praisenums[j] > 0)? PRAISENUMS[J]
+ "Great location"
: "";
System.out.println (j + 1 + "\t\t\t" + dishnames[j]
+ "\t\t\t" + prices[j] + "\t\t\t"
+ Praisenum);
}
The user begins to order and collects information
SYSTEM.OUT.PRINTLN ("Please select the number of the menu item:");
int choicename = Scanner.nextint ();
System.out.println ("Please enter your order number of servings:");
int number = Scanner.nextint ();
System.out.println ("Please enter the address of the delivery:");
String address = Scanner.next ();
System.out.println ("Please enter the time of delivery:");
System.out.println ("Shop on the Hour: 8 to 20");
int time = Scanner.nextint ();
Double sumprice = prices[choicename-1] * number;
Double Price = (Sumprice >=50)? 0:5;//determine if shipping is charged
SYSTEM.OUT.PRINTLN ("Order has been generated! ");
System.out.println ("You set the dish is:" + dishnames[choicename-1] + "\ T" + number+ "part");
System.out.print ("Meal Fee:" + sumprice);
System.out.print ("\ t room charge:" + price);
System.out.println ("\ t Total Cost:" + (price + Sumprice));
Insert information into an array
Times[i] = time; Time
Addresses[i] = address; Address
Sumprices[i] = (sumprice + price); Total Amount
Dishmsgs[i] = dishnames[choicename-1]; Set of dishes
States[i] = 0; Status of order
Numbers[i] = number; Number of copies
Break
}
}
if (!empty) {//the meal bag is full
System.out.println ("The meal Bag is full");
}
Break
Case 2:
System.out.println ("************ View Meal Bag ************");
System.out.println ("Number \t\t \t\t dishes (number of servings) \t\t delivery time \t\t delivery address \t\t total amount \t\t status \t\t like Quantity");
for (int i = 0; i < names.length; i++) {
if (names[i]! = NULL) {//someone ordered the display of the meal
String state = (States[i] = = 0)? "Already Booked": "Completed"; Get status
int time = Times[i]; Time
String Sumprice = sumprices[i] + "meta"; Total Amount
String address = addresses[i]; Address
String dishmsg = dishmsgs[i]; Food Products
int count = numbers[i];//number of copies
System.out.println ((i + 1) + "\t\t" + names[i] + "\t\t" + dishmsg + "(" + Count + ")" + "\t\t" + time+ "\t\t" + address + "\t\t" + sumprice+ "\t\t" + state + "\t\t" + praisenums[i]);
}
}
Break
Case 3:
SYSTEM.OUT.PRINTLN ("************ sign Order ************");
System.out.println ("Please enter the order number you need to sign for:");
int sign = Scanner.nextint ();
int flag = 0;//Make a mark to determine if the order is signed
for (int i = 0; i < names.length; i++) {
if (names[i]! = null && states[i] = = 0) {//have orders and can sign for
States[i] = 1;//change state
flag = 1;
Break
} else if (names[i]! = null && states[i] = = 1) {//has an order and has been signed
flag = 2;
}
}
if (flag = = 1) {
SYSTEM.OUT.PRINTLN ("The order has been signed! ");
} else if (flag = = 2) {
SYSTEM.OUT.PRINTLN ("Order cannot be repeated for signature!") ");
} else {
System.out.println ("Did not find your order!") Please check your number! ");
}


Break
Case 4:
System.out.println ("************ Delete order ************");
System.out.println ("Please enter the order number you want to delete:");
int dealnum = Scanner.nextint ();
int deal = 0; Make a mark to determine if the order is signed and whether it exists
for (int i = 0; i < names.length; i++) {
if (names[i] = null && states[dealnum-1] = = 1) {//has an order and has been signed, can be deleted
Delete a message, and then move forward all the information
for (int j = dealNum-1; J < Names.length-1; J + +) {
NAMES[J] = names[j + 1]; Ordering people
DISHMSGS[J] = dishmsgs[j + 1];//Dishes
TIMES[J] = times[j + 1];//time
ADDRESSES[J] = addresses[j + 1];//Address
STATES[J] = states[j + 1];//status
NUMBERS[J] = numbers[j + 1];//Number of copies
}
Deal = 1;
Break
} else if (names[i]! = null && states[i] = = 0) {//Right order and the order has not been signed, it cannot be deleted
Deal = 2;
}
}
if (deal = = 1) {
SYSTEM.OUT.PRINTLN ("The order has been deleted");
} else if (deal = = 2) {
SYSTEM.OUT.PRINTLN ("The order has not yet been signed not allowed to delete!" ");
} else {
SYSTEM.OUT.PRINTLN ("No orders found!") ");
}
Break
Case 5:
System.out.println ("************ I like ***************");
System.out.println ("number \t\t\t dish name \t\t\t price");
for (int i = 0; i < dishnames.length; i++) {//traversal of all dish names
String Price = Prices[i] + "meta"; Price
String name = dishnames[i];//dish name
System.out.println ((i + 1) + "\t\t\t" + name + "\t\t\t" + price);
}
SYSTEM.OUT.PRINTLN ("Please input the number of dishes you like:");
int choicenum = Scanner.nextint ();
praisenums[choicenum-1]++;//the number of points of praise accumulation
SYSTEM.OUT.PRINTLN ("Thank you for participating!" Praise Success! ");
Break
Case 6:
Exit system
Isexit = true;
Break
Default
Exit system
Isexit = true;
Break
}
if (!isexit) {//default this is not exited
System.out.println ("Enter 0 to return to the main menu! ");
num = Scanner.nextint ();
} else {
Break Exit system
}
} while (num = = 0);
SYSTEM.OUT.PRINTLN ("Thank YOU for coming!!!!! ");
}
}

Simple "Order System" (for Beginners) with basic Java knowledge

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.