Food Menu Program

Problem: Create a Java Program that uses Control Statements (must use switch-case statement and ladderized if-else ) that presents a menu of a fast food chain at least 5.

Consider the following:
a. The user of your program is the costumer.
b. The Costumer selects one menu.
c. Consider Discounts
         c.1  If the costumer is a Senior Citizen (give 20% Discount from the total amount due)
         c.2 If the costumer is a Student (give 5.5% Discount)
         c.3 If None of the (2) options No Discount will be given

Code
package oop;
import java.util.Scanner;
public class Oop {
    static Scanner gene=new Scanner(System.in);
    public static void main(String[] args) {
        String answer; char choose;
        do
        {
        int order,cash; double price=0,select,discount=0,total=0,fee=0;
        System.out.println("**OUR MENU**");
        System.out.println("[1] Burger and Fries           P100");
        System.out.println("[2] Cake and Ice Cream         P120");
        System.out.println("[3] Chicken and Rice with coke P150");
        System.out.println("[4] Special Palabok            P200");
        System.out.println("[5] Lechon Baboy               P300");
        System.out.println("\nEnter your order:");
        order=gene.nextInt();
        if((order>=1)&&(order<=5))
        {switch (order){
   
            case 1: System.out.println("\nBurger and Fries");
                    price=100;break;
            case 2: System.out.println("\nCake and Ice Cream");
                    price=120; break;
           
            case 3: System.out.println("\nChicken and Rice with Coke");
                    price=150; break;
           
            case 4: System.out.println("\nSpecial Palabok");
                     price=200;break;
               
            case 5: System.out.println("\nSpecial Palabok");
                       price=300;break;
                   
            default:System.out.println("none"); break;
        }
        System.out.println("[1]Senior\n[2]Student\n[3]None\n\nEnter your choice:");
          select=gene.nextInt();
          if(select==1)
              discount=price*.20;
         
          else if(select==2)
              discount=price*.15;
           
          else if(select==3)
              discount=0;
          total=price-discount;
          System.out.println("Enter your amount:");
          cash=gene.nextInt();
          fee=cash-total;
          System.out.println("\nDiscount="+discount+"\nAmount to pay="+price+"\nChange="+fee);
        }
        else
            System.out.println("invalid");
             System.out.println("\nDo you want to try again?");
        answer=gene.next();
        choose=answer.charAt(0);
        } while(choose=='y'||choose=='Y');
        System.out.println("Dumo-Arigatou");
     
   
    }
}


0 comments :

Post a Comment

 
My IT Life © 2011-2014|Gene Rose