# CPAN116 – Algorithms & Problem Solving – Lab 2

## Assignment Content

### Lab 2 – Restaurant Bill (3%)

Define the problem and outline the solution for the given scenario.

• You are asked to design an algorithm that calculates the total amount of a meal. It asks to enter the charges for the food purchased in dollars and cents. Calculate the sales tax of 7% and display it. Calculate the tip of 15% and display it. Sales tax and tip must be calculated separately on the total amount of meal purchased. Finally, it displays the total amount after tax and tip is included.
• You can use the following table format to define the problem and then outline a solution.
 Input Processing Output
• Write pseudocode or Java program to develop the outline into an algorithm.
• Declare and use constants in pseudocode/Java program as appropriate.
• Here are the two sample screen shots:

1.
How much does the meal cost?
235.78
Net Amount(excluding tax): \$235.78
Tax (7%): \$16.50
Tip (15%): \$35.37
Gross Amount (including tax and tip): \$287.65

2.
How much does the meal cost?
300
Net Amount(excluding tax): \$300.0
Tax (7%): \$21.00
Tip (15%): \$45.00
Gross Amount (including tax and tip): \$366.00

Note: Numbers in green font are inputs and with normal font are outputs. In Java, we use double as a data type to represent a decimal number.