Have to use parallel arrays, one for the menu items, and another one for the pri
ID: 3717200 • Letter: H
Question
Have to use parallel arrays, one for the menu items, and another one for the prices.
You have been approached to create a computer program that ill accurately calculate bills for each customer 1. Kids, under 5, eat free 2. Teens and seniors get a 25% discount. Also 1. Food and beverage is taxed at 5%. 2. No tax for anything a senior or teen orders and eats. Every person who eats at this restaurant orders exactly three items. Never greater, never fewer The menu is limited Menu Item Soup Wings Burger Chicken sandwich 5.95 Fries Pie Ice cream Soft drink Coffee Price 2.50 15 each 4.95 1.99 2.95 2.99 1.50 1.00 Write a program that will accurately determine a bill. Programs must be tested. In order to test this program, use the following scenarido A family stops at the restaurant for lunch. The family is composed of a middle aged mother and father named Bill and They have a 2-year old child named Jesse. They are traveling with Nancy's elderly grandmother, Sarah. Everybody decided to order a burger. Nancy and Jesse order a soft drink. Nancy and Sarah order soup. Bill orders 5 vw Bill and Sarah order coffee. Jesse orders ice cream. Run your program one time for each person and determine the grand total this family would owe on their billExplanation / Answer
Program:
import java.util.Scanner;
public class Restraunt {
public static void main(String[] args) {
//Declaring variables to hold the cost of each item
double soup=2.50;
double wings=0.15;
double burger=4.95;
double chickenSandwich=5.95;
double fries=1.99;
double pie=2.95;
double icecream=2.99;
double softDrink=1.50;
double coffee=1.00;
//declaring variables to hold the count of each item
int soupCount=0;
int wingsCount=0;
int burgerCount=0;
int chickenSandwichCount=0;
int friesCount=0;
int pieCount=0;
int icecreamCount=0;
int softDrinkCount=0;
int coffeeCount=0;
//char variable to know whether to continue to input new customer or not
char isContinued;
//variable to calculate bill amount
double billAmount;
//totalamount to be displayed at the end
double totalAmount=0.0;
//looping to input the orders from each customer
do{
Scanner sc=new Scanner(System.in);
System.out.println("enter name of the customer");
String name=sc.nextLine();
System.out.println("enter age of the customer");
int age=sc.nextInt();
System.out.println("name:"+name+" age:"+age);
System.out.println("enter menu for "+name);
System.out.println("enter number of soup");
soupCount=sc.nextInt();
System.out.println("enter number of wings");
wingsCount=sc.nextInt();
System.out.println("enter number of Burger");
burgerCount=sc.nextInt();
System.out.println("enter number of chickenSandwich");
chickenSandwichCount=sc.nextInt();
System.out.println("enter number of fries");
friesCount=sc.nextInt();
System.out.println("enter number of pie");
pieCount=sc.nextInt();
System.out.println("enter number of icecream");
icecreamCount=sc.nextInt();
System.out.println("enter number of softdrink");
softDrinkCount=sc.nextInt();
System.out.println("enter number of coffee");
coffeeCount=sc.nextInt();
//calculating the final bill amount based on the age
if(age<5){
billAmount=0;
}
//condition to check for teenagers and senior citizens
else if(age>=60 ||(age<=19 && age>=5))
{
billAmount=(soupCount*soup)+(wingsCount*wings)+(burgerCount*burger)+(chickenSandwichCount*chickenSandwich)+(friesCount*fries)+(pieCount*pie)+(icecreamCount*icecream)+(softDrinkCount*softDrink)+(coffeeCount*coffee);
//Discounting 25% on bill amount for senior citizens and teen agers
billAmount=billAmount-(billAmount/4);
}
else{
billAmount=(soupCount*soup*1.05)+(wingsCount*wings*1.05)+(burgerCount*burger*1.05)+(chickenSandwichCount*chickenSandwich*1.05)+(friesCount*fries*1.05)+(pieCount*pie*1.05)+(icecreamCount*icecream)+(softDrinkCount*softDrink*1.05)+(coffeeCount*coffee*1.05);
//1.05 is multiplied because 5% tax is levied on the beverages and foods
}
System.out.println("Do You Want to continue with another customer(y/n)");
isContinued=sc.next().charAt(0);
totalAmount=totalAmount+billAmount;
}while(isContinued=='y');
//printing the final amount to be paid
System.out.println("Total Amount to be paid is:"+totalAmount);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.