Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is Java and please make simple program and put // (comment) when as needed, Thank you. 1. Calculating a tip when you go to

This is Java and please make simple program and put // (comment) when as needed, Thank you.

1. Calculating a tip when you go to a restaurant based on service if something we all do. However, current tip recommendations are not based on degree of satisfaction. This program should create such a tip calculator.

In the Tip class:

a. Create a Tip class.

b. Create an instance variable called satisfactionRating. This variable should be an int.

c. Create a constructor. The constructor sets (initializes) satisfactionRating variable to the value in the parameter.

d. Create a method, calculateBill. It will calculates a tip, calcTip and add it to the cost of the meal. The method should have a double argument which you should name bill that represents the cost of the meal before the tip. Create a variable which is a double and called tip. If the satisfactionRating is 1, multiple the bill by 20% and assign it to the variable named tip. If the satisfactionRating is 2, multiple the bill by 15% and assign it to the variable named tip. If the satisfactionRating is 3, multiple the bill by 10% and assign it to the variable named tip. Add the tip to the bill and return the calculated value. The method should return a double which represents the numeric calculation of the tip + the cost.

In the tester class:

a. Create a main.

b. Create a Scanner object. (Dont forget you have to import it.)

c. Prompt the user to input the cost of the meal.

d. Create a double variable named mealCost and assign the user input to it.

e. Prompt the user to input a satisfaction rating of 1 for totally satisfied, 2 for satisfied, and 3 for dissatisfied.

f. Create an int named satisfaction and assign the user input to it.

g. Create a Tip object using satisfaction.

h. Call the method calculateBill and use mealCost your parameter input. Assign the returned value to a variable named totalCost. It should be a double.

i. Create a string variable named satisfactionLevel. You should convert the int satisfaction from the numerical value to the appropriate word representation. For example, if(satisfaction == 1) { satisfactionLevel = Totally Satisfied;}

j. Print the satisfactionLevel so that it reads Satisfaction is: XXXX.

k. Print the cost of the meal. This was input in step d. It should read The cost of the meal was: XXX.

l. Print the totalCost of the meal. It should read The total cost of the meal was: xxx.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

5. Why is the Civil Rights Act of 1991 such a significant law?

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago