In this assignment, you will develop a Java console app to calculate tips. We will break the code for this assignment into two separate classes.
This class encapsulates the tip calculation logic. It may be reused with a different user interface in a future assignment.
Data Members
The class should have the following private data members:
Methods
The class should have the following methods:
This class encapsulates the user interface of the app.
Data Members
Methods
TipApp calculateTips()
1. Create a Scanner object to read input from the keyboard.
2. Prompt for and read the bill amount. If an invalid numeric value is entered by the user, print an error message and repeat the process until a valid value is entered. When a valid value is entered, use it to set the bill amount data member for the TipCalculator object.
3. Prompt for and read the tip percentage. If an invalid numeric value is entered by the user, print an error message and repeat the process until a valid value is entered. When a valid value is entered, use it to set the tip percentage data member for the TipCalculator object.
4. Prompt for and read the party size. If an invalid numeric value is entered by the user, print an error message and repeat the process until a valid value is entered. When a valid value is entered, use it to set the party size data member for the TipCalculator object.
5. Call the various TipCalculator methods to produce the output.
6.Ask the user whether they want to continue (enter another bill amount, tip percentage and party size) and read their response. If the response is y or Y, go back to Step 2 and repeat.
A sample run of the app might look something like this:
*** Tip Calculator ***
Enter the bill amount: 105.37
Enter your desired tip percentage (20 equals 20%): 2a
Please enter a valid tip percentage.
*** Your Bill ***
Bill Amount: $105.37
Tip Percentage: 20%
Party Size: 3
Total Bill (with Tip): $126.44
Share for Each Individual: $42.15
Another bill? (y/n): y
*** Your Bill ***
Enter the bill amount: 78.27
Enter your desired tip percentage (20 equals 20%): 23
Enter the size of your party: 2
Bill Amount: $78.27
Tip Percentage: 23%
Party Size: 2
Total Bill (with Tip): $96.27
Share for Each Individual: $48.14
Another bill? (y/n): N
Goodbye!