Write a Java program called 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

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.text.NumberFormat;
import java.util.Scanner;

class Solution
    public static void main( String[] args )
       // Declear double bill and int tipPercent to read from Scanner input
       double bill;
       int tipPercent;
       // Creat a Scanner instance in.
       Scanner in = new Scanner(;
       // 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...

By purchasing this solution you'll be able to access the following files:

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats