0% found this document useful (0 votes)
43 views11 pages

Computer Project Menu: Program Outline

The document describes a Java program for a café menu with 5 food options. The program uses arrays and methods to display the menu, accept a customer's selection, calculate the item price, and print the total bill. Methods are used to handle selections for beverages, sandwiches, cakes, ice cream, and donuts. The main method controls the program flow, running the order and billing process until the customer stops purchasing items.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views11 pages

Computer Project Menu: Program Outline

The document describes a Java program for a café menu with 5 food options. The program uses arrays and methods to display the menu, accept a customer's selection, calculate the item price, and print the total bill. Methods are used to handle selections for beverages, sandwiches, cakes, ice cream, and donuts. The main method controls the program flow, running the order and billing process until the customer stops purchasing items.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Program outline:

A menu for a caf that offers five choices of food to customers.



Program code:-
import java.io.*;
class cafe
{ double cost=0;
int n=100;
int z=0;
String name[]=new String[n];
double price[]=new double[n];
public static void main(String args[]) throws IOException
{
BufferedReader std=new BufferedReader(new InputStreamReader(System.in));
double billamt=0;
String st;
while(true)
{ System.out.println("WELCOME TO CAFE DUE REVOIRE");
cafe obj=new cafe();
do
{
System.out.println("Take your pick:");
System.out.println("1.Beverages");
System.out.println("2.Sandwiches");
System.out.println("3.Cakes");
System.out.println("4.Ice creams");
System.out.println("5.Donuts");
System.out.print("Enter the number of your choice:");
int c=Integer.parseInt(std.readLine());
switch(c)
{ case 1: obj.Beverages();break;
case 2: obj.Sandwiches();break;
case 3: obj.Cakes();break;
case 4: obj.Ice_creams();break;
case 5: obj.Donuts();break;
default: System.out.println("please check your input");
}
System.out.println("Please type 'stop' if you want to stop.");
System.out.println("Type anything else if you want to continue buying...");
st=std.readLine();
}
while(!(st.equalsIgnoreCase("stop")));
{
System.out.println("Your bill:");
System.out.println();
System.out.println("Sl.no \t Item name \t \t \t Cost of the item");
for(int i=0;i<obj.z;i++)
{ System.out.println(i+1+"\t"+obj.name[i]+"Rs."+obj.price[i]);
}
billamt+=obj.cost;
System.out.println("Grand Total:"+billamt);
System.out.println("Hope you had fun! Come back soon!!");
System.out.println("Are there any more customers?");
System.out.println("Enter 'no' if there are no more customers.");
String str =std.readLine();
if(str.equalsIgnoreCase("no"))
break;
}
}
}
public void Beverages()throws IOException
{ BufferedReader std=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Your choices: 1.Coffee \n 2.Tea \n 3.Strawberry milkshake \n 4.Iced tea ");
System.out.println("enter the number of your choice:");
int chF=Integer.parseInt(std.readLine());
if(chF==1)
{ name[z]="Coffee";
price[z]=18;
z++;
System.out.println("the cost for your choice is Rs.18");
cost+=18;
}
else
if(chF==2)
{ name[z]="Tea";
price[z]=15;
z++;
System.out.println("the cost for your choice is Rs.15");
cost+=15;
}
else
if(chF==3)
{ name[z]="Strawberry milkshake";
price[z]=22;
z++;
System.out.println("the cost for your choice is Rs.22");
cost+=22;
}
else
if(chF==4)
{ name[z]="Iced tea";
price[z]=20;
z++;
System.out.println("the cost for your choice is Rs.20");
cost+=20;
}
else
System.out.println("please check your input");
}

public void Sandwiches()throws IOException
{ BufferedReader std=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Your choices: 1.Spinach and corn \n 2.Grilled cheese \n 3.Cucumber and
tomato \n 4.Peanut butter and jelly \n 5.Chutney");
System.out.println("enter the number of your choice:");
int chF=Integer.parseInt(std.readLine());
if(chF==1)
{ name[z]="Spinach and corn";
price[z]=299;
z++;
System.out.println("the cost for your choice is Rs.299");
cost+=299;
}
else
if(chF==2)
{ name[z]="Grilled cheese";
price[z]=299;
z++;
System.out.println("the cost for your choice is Rs.299");
cost+=299;
}
else
if(chF==3)
{ name[z]="Cucumber and tomato";
price[z]=199;
z++;
System.out.println("the cost for your choice is Rs.199");
cost+=199;
}
else
if(chF==4)
{ name[z]="Peanut butter and jelly";
price[z]=109;
z++;
System.out.println("the cost for your choice is Rs.109");
cost+=109;
}
else
if(chF==5)
{ name[z]="Chutney";
price[z]=99;
z++;
System.out.println("the cost for your choice is Rs.99");
cost+=99;
}
else
System.out.println("check your input");
}

public void Cakes()throws IOException
{ BufferedReader std=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Your choices: 1.Black forest \n 2.Blueberry \n 3.Dark fantasy \n 4.Chocolate
mousse \n 5.Butterscotch");
System.out.println("enter the number of your choice:");
int chF=Integer.parseInt(std.readLine());
if(chF==1)
{ name[z]="Black forest";
price[z]=299;
z++;
System.out.println("the cost for your choice is Rs.299");
cost+=299;
}
else
if(chF==2)
{ name[z]="Blueberry";
price[z]=499;
z++;
System.out.println("the cost for your choice is Rs.499");
cost+=499;
}
else
if(chF==3)
{ name[z]="Dark fantasy";
price[z]=399;
z++;
System.out.println("the cost for your choice is Rs.399");
cost+=399;
}
else
if(chF==4)
{ name[z]="Chocolate mousse";
price[z]=299;
z++;
System.out.println("the cost for your choice is Rs.299");
cost+=299;
}
else
if(chF==5)
{ name[z]="Butterscotch";
price[z]=199;
z++;
System.out.println("the cost for your choice is Rs.199");
cost+=199;
}
else
System.out.println("check your input");
}
public void Ice_creams()throws IOException
{
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Your choices: \n 1.Mango \n 2.Pista \n 3.Litchi \n 4.Chocolate \n 5.Vanilla");
int cha= Integer.parseInt(bf.readLine());
switch (cha)
{
case 1:name[z]="Mango";
price[z]=30;
z++;
cost+=30;
System.out.println("The cost of your purchase is Rs.30");
break;
case 2: System.out.println("The price for your purchase is: Rs.40");
name[z]="Pista";
price[z]=40;
z++;
cost+=40;
break;
case 3: System.out.println("The price for your purchase is: Rs.30");
name[z]="Litchi";
price[z]=30;
z++;
cost+=30; break;
case 4: System.out.println("The price for your purchase is: Rs.25");
name[z]="Chocolate";
price[z]=25;
z++;
cost+=25;
break;
case 5: System.out.println("The price for your purchase is: Rs. 22");
name[z]="Vanilla";
price[z]=22;
z++;
cost+=22;
break;
default: System.out.println("Please check your input");
}
}
public void Donuts()throws IOException
{
BufferedReader bfr= new BufferedReader(new InputStreamReader(System.in));
System.out.println("You choices:\n 1.Plain glazed \n 2.Chocolate \n 3.Chocolate with sprinkles");
int chr= Integer.parseInt(bfr.readLine());
switch(chr)
{
case 1: System.out.println("The price for your purchase is: Rs. 380/-");
name[z]="Original glazed";
price[z]=380;
z++;
cost+=380;
break;
case 2: System.out.println("The price for your purchase is: Rs. 450/-");
name[z]="Chocolate";
price[z]=450;
z++;
cost+=450;
break;
case 3: System.out.println("The price for your perchase is: Rs. 400/-");
name[z]="Chocolate with sprinkles";
price[z]=400;
z++;
cost+=400; break;
default: System.out.println("Please check your input");
}
}
}

Variables description:
n: array variable
z: array variable
cost: cost of the item
billamt: to calculate the total amount
i: loop variable
st: string variable for continuation of program
chF: variable to identify choice in if statement
name: name of the article in the array
price: article price in array

Method description:
Main method: method to find out the cost of each article, the total price and print the amount on
the bill.
Methods Donuts: method to accept the choice of donuts and calculate and print the price of the
choice

You might also like