Write a Java program called Solution.java that will calculate the tip to leave at a restaurant. Your program must ask the user for the amount of the bill (this could contain decimals), and the percent they want to tip. The user will enter the percent they want to tip as an integer, e.g. 15 for 15%. Then your program should calculate and display the tip amount and the total bill after including the tip. To calculate the tip amount, multiply the bill amount times the percent divided by 100 (be careful of integer division).
Make sure to use the following:
- Comments explaining the main parts of the code (Getting input, calculating results, etc)
- Descriptive variable names with appropriate types
- Appropriate indentation between braces
- The NumberFormat class to format the output to be display as currency
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
public static void main( String args )
// Declear double bill and int tipPercent to read from Scanner input
// Creat a Scanner instance in.
Scanner in = new Scanner(System.in);
// Message to prompt a user to input amount of bill and tip separated by a space
System.out.println( "Enter the amount of the bill and the percent you want to tip separated by a space: " );
bill = in.nextDouble(); // assign the bill supplied by the user to bill
tipPercent = in.nextInt(); // assign the tip % supplied by the user to tipPercent...
This is only a preview of the solution. Please use the purchase button to see the entire solution