Saturday, November 14, 2020

ICSE BlueJ Project On Restaurant (2)

   import java.util.*;
class Restaurant
{
 String item[]={"Pasta","Cheese Pizza","Mini Burgers with Cheeze","Corn Dogs","Grilled Chicken","Chicken soup","Tomato soup","Meatloaf","Lasagna","Spaghetti with meatballs","Chicken parmesan","Chicken Pesto","Chrispy Popcorn","Tempura Green Beans","Double Decker Chicken","Pav Bhaji","Giant chocolate chip cookies","Banana split","Apple Cobbler","Samosa"};
 double rate[]={100,102,103,104,105,95,50,100,85,150,130,110,106,107,108,50,100,50,60,10};
 String order[]=new String[10];
 double amt[]=new double[10];
 String ans;
 int plates[]=new int[10];
 int i,n=0,no,x=0;
 Scanner sc=new Scanner(System.in);
 Restaurant()
 {
  
 } 
 
 public void init()
 {
     System.out.println("*********************WELCOME TO MAJI'S CANTEEN*************************\n\n\n");
      System.out.println("\n\n\n*************MENU CARD************\n\n\n");
      System.out.println("*********************************************");
      System.out.println("Item No.         Item            Rate/plate");
      for(i=0;i<20;i++)
      {
                System.out.println((i+1)+ ":                "+item[i]+"------------------"+rate[i]);
      }
       System.out.println("\nFor Purchase of Rs. 500 or More, 12.5% Discount ");         
     while(true)
     {
          if(x==20)
          break;
         System.out.println("Enter item number:");
         no=sc.nextInt();
         order[x]=item[no-1];
         amt[x]=rate[no-1];
         System.out.println("How many plates?:");
         no=sc.nextInt();
         plates[x]=no;
         x++;
         sc=new Scanner(System.in);
           System.out.println("Any More Item ?(Y/N):");
        ans=sc.nextLine().toUpperCase();
             if(ans.equals("N"))
             break;
 }
 display();
}
private void display() 
{
double bamt=0,b;
  System.out.println("You have ordered\n");
   System.out.println("Item       Rate         No. of Plates");
  for(i=0;i< x;i++)
  {
       System.out.println((i+1)+":"+order[i]+"---"+amt[i]+"---"+plates[i]);
    }   
        
         System.out.println("MAJI'S CANTEER\nCash Memo\n");        System.out.println("*****************************************************************");
        System.out.println("Item          No. of plates      Rate           Amount\n");         System.out.println("***************************************************************");
         for (i=0;i<x;i++)
         {
               System.out.print(order[i]+ "             "+plates[i]+ "              "+ amt[i]+ "                      ");      
        b=plates[i]*amt[i];
         System.out.println(b);
         bamt=bamt+b;
        }
         System.out.println("Bill Amount (Including All) Rs.                                     "+bamt);
          System.out.println("*******************");
          if(bamt>=500)
          System.out.print("Total Amount after discount @ 12.5% Rs.                  ");
          else
          System.out.print("Total Amount Rs.                   ");
          if (bamt>=500)
          bamt=bamt-bamt*.125;
          System.out.println(bamt);        
}
public static void main(String args[]) throws Exception
{
Restaurant ob=new Restaurant();
 ob.init();
}
}


Variable description of the program




String item[] holds the items in the menu
double rate[] holds the rate of the items of menu card
String order[] it holds the items ordered by any customer
double amt[] it holds the price of items ordered
String ans It takes the choice of customer whether any more order is to be taken
int plates[] it holds the number of plates of each items ordered by customer
int x customer has to order atleast two items, ‘x’ keeps track of the number of items ordered.
int no items are ordered using the item number. ‘no’ holds the item number.
int i loop control variable.
double bamt holds the total bill amount
BufferedReader br It is used to take user input

*/


No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner