Question: Programming Fundamentals Tipping App 1. Since the program uses input and message dialog boxes, import the JOptionPane class. 2.Declare the following variables and constant:a.AString that

Programming Fundamentals

Tipping App

1. Since the program uses input and message dialog boxes, import the JOptionPane class.

2.Declare the following variables and constant:a.AString that will hold the users input from each of two different input dialog boxesb.A doublevariablefor the cost of the mealthatcan be initialized to 0c.An int variable that will hold the users selection from a set of options in one of the input dialog boxesthatcan be initialized to 0d.Aconstantdoublefor the sales tax of 6.75% that will be applied to the meal cost(keep in mind this should be written as a decimal rather than a percentage)

3.Display an input dialog box asking the user how much the meal cost. After storing the users inputinto the String variable, convert the input to a doubleandstoreitinto the variable for the cost of the meal.

4.Multiply the cost of the meal by1 plusthe sales tax and store the result back into the variable for the cost of the meal. (Hint: This can be done with a combined assignment operator.)

5.Display an input dialog box asking the user to select from one of three options: leave 15%, leave 20%, or round to the nearest dollar above 15%.After storing the users input into the String variable, convert the input into an int and store it into the variable for the users selection.

6.Based on the users selection, you will choose from one of three options by using if-else if-else statements:a.If the user enters 1, this means they are leaving 15%.b.Else if the user enters 2, this means they are leaving 20%.c.Else, the user must have entered3.This means they are leaving the nearest wholedollar amount greater than 15%. For example, if the meal with a 15% tip would be $15.26, they are going to leave $16.00.

7.For options 1 and 2(part a and b of step 6), multiply the cost of the meal by 1 plus the specified tip amount and store the result back into the variable forthe cost of the meal. For option 3(part c of step 6), you will multiply the cost of the meal by 1 plus the 15% tip amount and then use the Math.ceil(amount) method to round the result up to the nearest whole number.

8.After calculating the total cost of the meal, include a message dialog box stating the total cost to the user.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!