divider

Objective

Create a console application that helps users calculate the tip amount based on their bill subtotal and a given tip percentage.

Terms
  • icon Bill/Subtotal: The cost of your food and drink
  • icon Tip/Gratuity: Additional payment given for a service
  • icon Total: The sum of the subtotal and the tip

Example 1: A $10 bill with 20% tip = $2 tip; $12 total

Example 2: A $25 bill with 18% tip = $4.50 tip; $29.50 total

Skills to Practice

  • icon Prompting a user for input
  • icon Saving user input to variables
  • icon Converting input to the correct data type (if necessary)
  • icon Performing arithmetic calculations
  • icon Formatting custom output using variables
divider

Tasks

  • icon Create a project named tipcalculator-lastname.
  • icon Complete the following tasks:
    • icon Prompt the user to enter the bill subtotal.
    • icon Prompt the user to enter the tip percentage as a whole number. For example, 20 means 20%.
    • icon Calculate the tip amount.
    • icon Formula: Tip = Subtotal × (TipPercentage ÷ 100)
    • icon Calculate the total amount.
    • icon Display the calculated tip amount and total amount to the user in a clear and formatted manner.
    • icon If you want to ensure your dollar amount always has two decimal places, google search how to accomplish this with your respective programming language.

Sample Output

Sample Output
--- Tip Calculator ---
Enter the bill subtotal: 50.00 [Enter]
Enter the tip percentage: 15 [Enter]
Tip amount: $7.50
Total amount: $57.50

Begin Challenge