Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need Help For Assignment (Write a java program that simulates a simple food ordering system)

Kelvin CklKelvin Ckl KlangMember Posts: 5

rite a program that simulates a simple food ordering system. The program should start with displaying a menu
with the following options:
Main Menu
(1) Place Order
(2) Payment
(3) Quit
If the user chooses Place Order option, the program should display a sub-menu to choose either to order drinks or
food. The sub-menu may look like follows:
Order Menu
(1) Drinks
(2) Food
(3) Back to Main Menu
Each option (Drinks or Food) should display several options of food/drinks together with their prices. The
following shown an example food menu. You may list your own food and prices in your program.
Food Menu
(1) Nasi Lemak RM5.00
(2) Roti Canai RM1.50
(3) Fried Noodle RM3.50
(4) Back to Order Menu
The user should be allowed to order as many food/drink as he/she wants. For each order, the user need to enter
the quantity needed. If the user chooses Payment option, the program should display the total price need to be
paid. Then prompt the user whether there is a discount given. If there is a discount, read the discount rate in
percentage (e.g. enter 5 for 5% discount) and deduct the discount amount from the total price. Continue to read an
amount paid by the user, and display the balance need to be paid back to the user. After the payment is done, allow
user to go back to the main menu so that another order can be made.
Remember to re-initialize all variables after payment is done before a new order is made.

Comments

  • Kelvin CklKelvin Ckl KlangMember Posts: 5

    SJ Restaurant Ordering System

    Main Menu

    (1) Place Order
    (2) Payment
    (3) Quit
    Enter your choice: 1

    Order Menu

    (1) Drinks
    (2) Food
    (3) Back to Main Menu
    Enter your choice: 2

    Food Menu

    (1) Nasi Lemak RM5.00
    (2) Roti Canai RM1.50
    (3) Fried Noodle RM3.50
    (4) Back to Order Menu
    Enter order: 1
    Enter quantity: 2

    Food Menu

    (1) Nasi Lemak RM5.00
    (2) Roti Canai RM1.50
    (3) Fried Noodle RM3.50
    (4) Back to Order Menu
    Enter order: 4

    Order Menu

    (1) Drinks
    (2) Food
    (3) Back to Main Menu
    Enter your choice: 3

    Main Menu

    (1) Place Order
    (2) Payment
    (3) Quit
    Enter your choice: 2

    Order Quantity Unit Price Total

    Nasi Lemak 2 5.00 10.00
    Overall Total: 10.00
    Payment: 50.00
    Balance: 40.00

  • Kelvin CklKelvin Ckl KlangMember Posts: 5

    public class Assignment1Question2 {
    public static void main(String[] args)
    {
    Scanner read = new Scanner(System.in);
    int choice;
    int choice2;
    int choice6;
    double quantity=0;
    double quantity2=0;
    int order=0;
    int order3=0;
    int order4;
    int order5;
    double subtotal=0;
    double subtotal2=0;
    double milo=5.50;
    double coffee=1.50;
    double tea=3.50;
    double burger=5.00;
    double pizza=1.50;
    double nasilemak=3.50;
    double discount;
    double price;
    double discount2;
    double totalfinal;
    int order2=0;
    String output;
    String output2;
    double overalltotal;
    double total=0;
    double sum;
    double sum2;
    double total2=0

  • Kelvin CklKelvin Ckl KlangMember Posts: 5

    System.out.println("--------------------------------------------");
    System.out.println("SJ Restaurant Ordering System");
    System.out.println("--------------------------------------------");
    System.out.println("Main Menu");
    System.out.println("--------------");
    System.out.println("(1) Place Order");
    System.out.println("(2) Payment");
    System.out.println("(3) Quit");
    System.out.print("Enter your choice:");
    choice=read.nextInt();

          if(choice==1)
            {
             System.out.println("Order Menu");
             System.out.println("------------");
             System.out.println("(1) Drinks");
             System.out.println("(2) Food");
             System.out.println("(3) Back to Main Menu)");
             System.out.println("Enter your choice:");
             choice2=read.nextInt();
              if(choice2==1)
              {
                 System.out.println("Drinks Menu");
                 System.out.println("--------------");
                 System.out.println("(1)Milo + \t\t + RM5.00");
                 System.out.println("(2) Coffee + \t\t RM1.50");
                 System.out.println("(3) Tea+ \t\t RM3.50");
                 System.out.println("(4) Back to Order Menu");
                 System.out.println("Enter order:");
                 order=read.nextInt();
                 switch (order) {
                 case 1:
                 System.out.println("Enter quantity:");
                 quantity=read.nextDouble();
                 subtotal=milo;
                 total=(subtotal * quantity);
                 sum=total;
                 output="milo" +1;  
                 break;
    
                 case 2:
                 System.out.println("Enter quantity");
                 quantity=read.nextDouble();
                 subtotal=coffee;
                 total=(subtotal * quantity);
                 sum=total;
                 output="coffee"+1;
                 break;       
    
                case 3:
                System.out.println("Enter quantity");
                quantity=read.nextDouble();
                subtotal=tea;
                total=(subtotal * quantity);
                sum=total;
                output="tea" +1;
                return;
    
                default:
                break;
                 }
    
  • Kelvin CklKelvin Ckl KlangMember Posts: 5

    }else
    if(choice2==2)
    {
    System.out.println("Food Menu");
    System.out.println("--------------");
    System.out.println("(1)Burger + \t\t + RM5.00");
    System.out.println("(2) Pizza + \t\t RM1.50");
    System.out.println("(3) Nasilemak+ \t\t RM3.50");
    System.out.println("(4) Back to Order Menu");
    System.out.println("Enter order:");
    order2=read.nextInt();
    switch(order2)
    {
    case'1':
    System.out.println("Enter quantity:");
    quantity2=read.nextDouble();
    subtotal2=burger;
    total2=(subtotal2*quantity2);
    sum2=total2;
    output2="burger"+1;
    break;

                   case'2':
                   System.out.println("Enter quantity:");
                   quantity2=read.nextDouble();
                   subtotal2=pizza;
                   total2=(subtotal2*quantity2);
                   sum2=total2;
                   output2="pizza"+1;
                   break;
    
                   case'3':
                   System.out.println("Enter quantity:");
                   quantity2=read.nextDouble();
                   subtotal2=nasilemak;
                   total2=(subtotal2*quantity2);
                   sum2=total2;
                   output2="nasilemak"+1;
                   break;  
    
                   case'4':
                   System.out.println("Food Menu");
                   System.out.println("--------------");
                   System.out.println("(1)Burger + \t\t + RM5.00");
                   System.out.println("(2) Pizza + \t\t RM1.50");
                   System.out.println("(3) Nasilemak+ \t\t RM3.50");
                   System.out.println("(4) Back to Order Menu");
                   System.out.println("Enter order:");
                   order3=read.nextInt();
                   break;
    
                   default:
                   System.out.println("please enter a valid choice!!!");
                   break;
                     }         
              }else
               if(choice==3){
                 System.out.println("Goodbye!!!");
                 }
           else
             if (choice==2)
             { 
                 System.out.println("Order \t\t Quantity\t\t Unit\t\t Price\t\t Total\t\t");
                 System.out.println("-----------------------------------------------");
                 System.out.println(order);
                 System.out.println(quantity);
                 System.out.println(subtotal);
                 System.out.println(total);
    
                 System.out.println(order2);
                 System.out.println(quantity2);
                 System.out.println(subtotal2);
                 System.out.println(total2);
    
                 overalltotal=total + total2;
                 System.out.printf("Overall total is RM ",overalltotal);
                 System.out.println(" Any Discount: ");
                 discount=read.nextDouble();
                 discount2=discount/100;
                 price=overalltotal-(discount2*overalltotal);
                 System.out.println("Payment: ");
                 double payment=read.nextDouble();
                 double balance = payment-price;
                 System.out.println("Balance:" + balance);
    
               }
             if(choice==3)
             {
                System.out.println("Goobye!!");
             }
         }        
      }                         
    }                 
    
Sign In or Register to comment.