ou are in a job where you earn a tip for service. You need a Java program that will calculate how much to add to the bill after calculating gratuity. Your program will read the subtotal and the gratuity rate from the user, computes the gratuity and total and displays the results to the user. For example, if the user enters 10 for subtotal and 15 for gratuity rate, the program displays $1.5 for gratuity and $11.5 as total. Don’t worry that the format of the output is “$X.X” rather than “$X.XX”. To calculate a tip, calculate subtotal * rate / 100 To calculate the total bill, use the above calculation and add to the subtotal. Sample run: Enter the subtotal or the bill 10 Enter the gratuity rate 15 The amount for gratuity is $1.5 The total final bill is $11.5
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
You are in a job where you earn a tip for service. You need a Java program that will calculate how much to add to the bill after calculating gratuity. Your program will read the subtotal and the gratuity rate from the user, computes the gratuity and total and displays the results to the user.
For example, if the user enters 10 for subtotal and 15 for gratuity rate, the program displays $1.5 for gratuity and $11.5 as total. Don’t worry that the format of the output is “$X.X” rather than “$X.XX”.
To calculate a tip, calculate subtotal * rate / 100
To calculate the total bill, use the above calculation and add to the subtotal.
Sample run:
Enter the subtotal or the bill 10
Enter the gratuity rate 15
The amount for gratuity is $1.5
The total final bill is $11.5
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images