/**
* Program Name:ResturauntOrder.java
* Purpose:
* Date:Mar 29, 2012
*/
import java.text.DecimalFormat;
import java.util.Scanner;
public class ResturauntOrder
{
public static void main(String[] args)
{
// Create Scanner
Scanner input = new Scanner(System.in);
// 1. Display a title
System.out.println(" Welcome to my Café! \n******************************");
// 2. Ask the user to enter the number of people in the group
//final int ARRAY_SIZE;
System.out.print("How many people there are in your group: ");
//ARRAY_SIZE = input.nextInt();
int peopleInGroup = input.nextInt();
System.out.println("\nEach person will need to order an item from each menu category including \nappetizer, entree, dessert, and beverage.");
System.out.println("\nI will ask each diner for all their menu selections.");
// 3. Create and populate eight arrays, two for each sub-menu.
String[] appetizer = {"","No Selection","Deep Fried Calamari","Soup du Jour","Garden Salad","Garlic Bread"};
double[] appetizerPrice = {0.00,0.00,7.50,4.99,3.99,4.50};
String[] entree = {"","No Selection","Rib-Steak","Fettuccini Alfredo","Pan-Fried Sole","Mediterranean Platter","Vegetarian Lasagna"};
double[] entreePrice = {0.00,0.00,15.95,11.25,17.95,13.50,9.00};
String[] dessert = {"","No Selection","Ice Cream Sundae","Cheesecake","Chocolate Truffle Cake","Raspberry Mousse"};
double[] dessertPrice = {0.00,0.00,2.95,5.00,6.00,4.50};
String[] beverage = {"","No Selection","Water","Juice","Pop","Milk","Coffee","Tea"};
double[] beveragePrice = {0.00,0.00,0.00,2.00,2.00,2.00,1.75,1.75};
// 4. Declare and initialize a variable to hold the total bill for all the food ordered by the entire group
double totalBill = 0;
// 5. Next generate the food order by asking the user to select one item from each sub-menu for each diner
// i. Display the diner number that is currently ordering food
int i = 1;
int [] appetizerChoice = new int [i];
int [] entreeChoice = new int [i];
int [] dessertChoice;
int [] beverageChoice;
String [] appetizerString = {""};
String [] entreeString = {""};
[highlight]while(i < peopleInGroup | i == peopleInGroup)
{
while (appetizerChoice[i] < 1 | appetizerChoice[i] > 5)
{[/highlight]
System.out.println("\nNow taking diner #" + i + "'s order...\n-------------------------------");
System.out.println("\nPlease select one item from the Appetizer menu.");
System.out.println("1. ** No Selection ** $0.00");
System.out.println("2. Deep Fried Calamari $7.50");
System.out.println("3. Soup du Jour $4.99");
System.out.println("4. Garden Salad $3.99");
System.out.println("5. Garlic Bread $4.50");
System.out.print("\nWhat is your selection?");
appetizerChoice[i] = input.nextInt();
}
[highlight]switch(appetizerChoice[i])
{
case 1: appetizerString[i] = appetizer[1];
break;
case 2:appetizerString[i] = appetizer[2];
totalBill = totalBill + appetizerPrice[2];
break;
case 3: appetizerString[i] = appetizer[3];
totalBill = totalBill + appetizerPrice[3];
break;
case 4:appetizerString[i] = appetizer[4];
totalBill = totalBill + appetizerPrice[4];
break;
case 5:appetizerString[i] = appetizer[5];
totalBill = totalBill + appetizerPrice[5];
break;
default: System.out.println("You must make a valid choice...");
}[/highlight]
while (entreeChoice[i] < 1 | entreeChoice[i] > 6)
{
System.out.println("\nPlease select one item from the Entree menu.\n");
System.out.println("1. ** No Selection ** $0.00");
System.out.println("2. Rib-Steak $15.95");
System.out.println("3. Fettuccini Alfredo $11.25");
System.out.println("4. Pan-Fried Sole $17.95");
System.out.println("5. Mediterranean Platter $13.50");
System.out.println("6. Vegetarian Lasagna $9.00");
System.out.print("\nWhat is your selection?");
entreeChoice[i] = input.nextInt();
}
switch(entreeChoice[i])
{
case 1: entreeString[i] = entree[1];
break;
case 2: entreeString[i] = entree[2];
totalBill = totalBill + entreePrice[2];
break;
case 3: entreeString[i] = entree[3];
totalBill = totalBill + entreePrice[3];
break;
case 4: entreeString[i] = entree[4];
totalBill = totalBill + entreePrice[4];
break;
case 5: entreeString[i] = entree[5];
totalBill = totalBill + entreePrice[5];
break;
case 6: entreeString[i] = entree[6];
totalBill = totalBill + entreePrice[6];
break;
default: System.out.println("You must make a valid choice...");
}
i++;
}
System.out.println("\nThank You! Your order consists of:\n\t" + appetizerString +
"\n\t" + entreeString);
System.out.println("----------------------------------------------------"+
"\nOrder completed. Your total bill comes to $"+ totalBill +
"\n----------------------------------------------------");
}//end main
}//end class