Question

Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best...

Please write this code in JAVA lang., thank you!

Your spouse's cousin's nephew's dog's trainer's best friend owns a restaurant. That person is very bad at math and recently discovered that most customers have been significantly undercharged for meals.

You have been approached to create a computer program that will accurately calculate bills for each customer.

Kids, under 5, eat free.
Teens and seniors get a 25% discount.
Also,

Food and beverage is taxed at 5%.
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

Price

Soup

2.50

Wings

.15 each

Burger

4.95

Chicken sandwich

5.95

Fries

1.99

Pie

2.95

Ice cream

2.99

Soft drink

1.50

Coffee

1.00

Write a program that will accurately determine a bill.

Programs must be tested. In order to test this program, use the following scenario.

A family stops at the restaurant for lunch. The family is composed of a middle aged mother and father named Bill and Nancy. 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 wings. 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 bill.

---------------------------------------------------- Program Output----------------------------------------------------------------

Please input the number of people in your party...

Please type a value for NUMBER_IN_PARTY:4

Please input order information for person 1...

Is this person eligible for a discount? (enter a number 1 - 4)

1 - if CHILD 5 years of age or younger

2 - if TEEN between 13 and 19 years of age

3 - if SENIOR 65 years of age or older

4 - if NONE of the above

Please type a value for DISCOUNT_TYPE:4

Menu items that may be selected:

1 Soup

2 Wings

3 Burger

4 Chicken Sandwich

5 Fries

6 Pie

7 Ice Cream

8 Soft Drink

9 Coffee

Please select menu item 1 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:3

Please select menu item 2 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:2

Please enter number of wings to be ordered...

Please type a value for NUMBER_OF_WINGS:5

Please select menu item 3 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:9

Person 1 Total: $7.04 (Discount Type 4)

Please input order information for person 2...

Is this person eligible for a discount? (enter a number 1 - 4)

1 - if CHILD 5 years of age or younger

2 - if TEEN between 13 and 19 years of age

3 - if SENIOR 65 years of age or older

4 - if NONE of the above

Please type a value for DISCOUNT_TYPE:4

Menu items that may be selected:

1 Soup

2 Wings

3 Burger

4 Chicken Sandwich

5 Fries

6 Pie

7 Ice Cream

8 Soft Drink

9 Coffee

Please select menu item 1 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:3

Please select menu item 2 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:1

Please select menu item 3 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:8

Person 2 Total: $9.40 (Discount Type 4)

Please input order information for person 3...

Is this person eligible for a discount? (enter a number 1 - 4)

1 - if CHILD 5 years of age or younger

2 - if TEEN between 13 and 19 years of age

3 - if SENIOR 65 years of age or older

4 - if NONE of the above

Please type a value for DISCOUNT_TYPE:3

Menu items that may be selected:

1 Soup

2 Wings

3 Burger

4 Chicken Sandwich

5 Fries

6 Pie

7 Ice Cream

8 Soft Drink

9 Coffee

Please select menu item 1 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:3

Please select menu item 2 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:1

Please select menu item 3 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:9

Person 3 Total: $6.34 (Discount Type 3)

Please input order information for person 4...

Is this person eligible for a discount? (enter a number 1 - 4)

1 - if CHILD 5 years of age or younger

2 - if TEEN between 13 and 19 years of age

3 - if SENIOR 65 years of age or older

4 - if NONE of the above

Please type a value for DISCOUNT_TYPE:1

Menu items that may be selected:

1 Soup

2 Wings

3 Burger

4 Chicken Sandwich

5 Fries

6 Pie

7 Ice Cream

8 Soft Drink

9 Coffee

Please select menu item 1 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:3

Please select menu item 2 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:8

Please select menu item 3 (enter a number 1 - 9)

Please type a value for SELECTED_ITEM:7

Person 4 Total: $0.00 (Discount Type 1)

Grand Total for Order: $22.77

Please write this code in JAVA lang. thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM

package java_programs;

import java.util.Scanner;

public class bill {

   public static void main(String[] args) {

       double price [] = {0,2.5,0.15,4.95,5.95,1.99,2.95,2.99,1.5,1.00};
       int n;
       Scanner sc = new Scanner(System.in);
       System.out.println("Please input the number of people in your party...");
       System.out.print("Please type a value for NUMBER_IN_PARTY:");
       n =sc.nextInt();
       double bill=0.0;
       for(int i =1;i<=n;i++){
           int disc,item,no_of_wings;
           double temp = 0.0;
           System.out.println("Please input order information for person "+i);
           System.out.println("Is this person eligible for a discount? (enter a number 1 - 4)");
           System.out.println("1 - if CHILD 5 years of age or younger");
           System.out.println("2 - if TEEN between 13 and 19 years of age");
           System.out.println("3 - if SENIOR 65 years of age or older");
           System.out.println("4 - if NONE of the above");
           System.out.print("Please type a value for DISCOUNT_TYPE: ");
           disc = sc.nextInt();
           System.out.println("Menu items that may be selected:");
           System.out.println("1 Soup\n2 Wings\n3 Burger\n4 Chicken Sandwich\n5 Fries\n6 Pie\n7 Ice Cream\n8 Soft Drink\n9 Coffee");
           for(int j=1;j<=3;j++){
           System.out.println("Please select menu item "+j+" (enter a number 1 - 9)");
           System.out.print("Please type a value for SELECTED_ITEM:");
           item = sc.nextInt();
           if(item == 2){
               System.out.print("Please enter number of wings to be ordered...\nPlease type a value for NUMBER_OF_WINGS:");
               no_of_wings = sc.nextInt();
               temp+=no_of_wings*price[2];
           }else{
               temp+=price[item];
               }
           }
           if(disc == 1)
               temp =0.00;
           else if(disc == 2 || disc == 3)
               temp =0.75 *temp;
           else
               temp =1.05*temp;
           temp = Math.round(temp * 100.0) / 100.0;
           System.out.println("Person "+i+" Total: $"+temp+"(Discount Type "+disc+")");
           bill+=temp;
       }
       bill= Math.round(bill * 100.0) / 100.0;
       System.out.println("Grand Total for Order: $"+bill);
      
   }

}

OUTPUT

Please input the number of people in your party...
Please type a value for NUMBER_IN_PARTY:4
Please input order information for person 1
Is this person eligible for a discount? (enter a number 1 - 4)
1 - if CHILD 5 years of age or younger
2 - if TEEN between 13 and 19 years of age
3 - if SENIOR 65 years of age or older
4 - if NONE of the above
Please type a value for DISCOUNT_TYPE: 4
Menu items that may be selected:
1 Soup
2 Wings
3 Burger
4 Chicken Sandwich
5 Fries
6 Pie
7 Ice Cream
8 Soft Drink
9 Coffee
Please select menu item 1 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:3
Please select menu item 2 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:2
Please enter number of wings to be ordered...
Please type a value for NUMBER_OF_WINGS:5
Please select menu item 3 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:9
Person 1 Total: $7.04(Discount Type 4)
Please input order information for person 2
Is this person eligible for a discount? (enter a number 1 - 4)
1 - if CHILD 5 years of age or younger
2 - if TEEN between 13 and 19 years of age
3 - if SENIOR 65 years of age or older
4 - if NONE of the above
Please type a value for DISCOUNT_TYPE: 4
Menu items that may be selected:
1 Soup
2 Wings
3 Burger
4 Chicken Sandwich
5 Fries
6 Pie
7 Ice Cream
8 Soft Drink
9 Coffee
Please select menu item 1 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:3
Please select menu item 2 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:1
Please select menu item 3 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:8
Person 2 Total: $9.4(Discount Type 4)
Please input order information for person 3
Is this person eligible for a discount? (enter a number 1 - 4)
1 - if CHILD 5 years of age or younger
2 - if TEEN between 13 and 19 years of age
3 - if SENIOR 65 years of age or older
4 - if NONE of the above
Please type a value for DISCOUNT_TYPE: 3
Menu items that may be selected:
1 Soup
2 Wings
3 Burger
4 Chicken Sandwich
5 Fries
6 Pie
7 Ice Cream
8 Soft Drink
9 Coffee
Please select menu item 1 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:3
Please select menu item 2 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:1
Please select menu item 3 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:9
Person 3 Total: $6.34(Discount Type 3)
Please input order information for person 4
Is this person eligible for a discount? (enter a number 1 - 4)
1 - if CHILD 5 years of age or younger
2 - if TEEN between 13 and 19 years of age
3 - if SENIOR 65 years of age or older
4 - if NONE of the above
Please type a value for DISCOUNT_TYPE: 1
Menu items that may be selected:
1 Soup
2 Wings
3 Burger
4 Chicken Sandwich
5 Fries
6 Pie
7 Ice Cream
8 Soft Drink
9 Coffee
Please select menu item 1 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:3
Please select menu item 2 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:8
Please select menu item 3 (enter a number 1 - 9)
Please type a value for SELECTED_ITEM:7
Person 4 Total: $0.0(Discount Type 1)
Grand Total for Order: $22.78

Add a comment
Know the answer?
Add Answer to:
Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's ...

    Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best friend owns a restaurant. That person is very bad at math and recently discovered that most customers have been significantly undercharged for meals. You have been approached to create a computer program that will accurately calculate bills for each customer. Kids, under 5, eat free. Teens and seniors get a 25% discount. Also, Food and beverage is taxed at 5%. No tax for anything...

  • Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders...

    Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders that come in. This program will require multiple classes. Summary class, customer class, order class and the driver class. Summary class This class will keep track of the cost of the order and output a summary, which includes the total for the order. The methods in this class are static. There are no instance variables, and instead uses an Order object that is passed...

  • Problem 2: Point of Sale System The McDowell Restaurant chain has asked you to write a...

    Problem 2: Point of Sale System The McDowell Restaurant chain has asked you to write a menu program for their new Fast-food service machines. Your program already prints the following menu like this: ********************************************************************** McDowell’s Restaurant ********************************************************************** Make your selection from the menu below: 1. Regular Hamburger $1.50 2. Regular Cheeseburger $1.75 3. Fish Sandwich $2.50 4. Half-pounder with cheese $2.75 5. French Fries $0.99 6. Large Soft Drink $1.25 *********************************************************************** Select 1, 2, 3, 4, 5, or 6 -----...

  • You Do The Math: Calculating Energy Contribution of Carbohydrate, Fat, and Protein Calculate the missing values...

    You Do The Math: Calculating Energy Contribution of Carbohydrate, Fat, and Protein Calculate the missing values in the table (Ques. A%, Ques. B% etc.) and then answer the bottom two questions (I and J). Calories CHO (g) FAT (g) PRO (g) 770 Menu/Food Menu 1/McDonald's Burger Meal Double Quarter Pounder with Cheese French Fries - Large McCafe Chocolate Shake Totals Physiological fuel values 510 910 2190 42 66 136 244 99 9 Proportion (%) 100% Ques. A% Ques. B% 350...

  • Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you...

    Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter the number of toppings: 2 Enter topping #1: Whipped Cream Enter topping #2: Cinnamon Enter item #2: Tea Enter the number of toppings: 2 Enter topping #1: Milk Enter topping #2: Sugar May I take your order? This is the menu: Coffee Tea Pop How many items would you...

  • Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements...

    Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements description: Assume you work part-time at a sandwich store. As the only employee who knows java programming, you help to write a sandwich ordering application for the store. The following is a brief requirement description with some sample output. 1. Selecting bread When the program starts, it first shows a list/menu of sandwich breads and their prices, then asks a user to select a...

  • Assignment 1. You are to write a simple program using Netbeans Java IDE  that consists of two...

    Assignment 1. You are to write a simple program using Netbeans Java IDE  that consists of two classes. The program will allow the user to place an order for a Tesla Model X car. 2. Present the user with a menu selection for each option on the site. We will use JOptionPane to generate different options for the user. See the examples posted for how to use JOPtionPane. 3. Each menu will have multiple items each item will be in the...

  • You Do The Math: Calculating Energy Contribution of Carbohydrate, Fat, and Protein Read the instructions in...

    You Do The Math: Calculating Energy Contribution of Carbohydrate, Fat, and Protein Read the instructions in the textbook to learn how to do the math. Instead of doing your entire day’s intake as in the example, you are going to determine the percentage of carbohydrate, fat, and protein in each of four different menus from two popular fast food restaurants. Calculate the missing values in the table attached to the first question and answer the following ten questions to complete...

  • #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a...

    #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player and...

  • I really need help with this python programming assignment asap please double check indentations, thank you...

    I really need help with this python programming assignment asap please double check indentations, thank you We were unable to transcribe this imageEnter a drink option: Milk 22 Guest #1: a Please select the number of your entree choice 1) Planked salmon, 2) Prime rib, 3) Sesame tofu with spinach: 3 Please select the number of your dessert choice 27 1) Caramel oat bar, 2) Chocolate decadence, 3) Orange creme brulee: 1 Please select the number of your drink choice...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT