Back

Code Challenge 1.5 - Tip Calculator

divider

Objective

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

Terms
  • Bill/Subtotal: The cost of your food and drink
  • Tip/Gratuity: Additional payment given for a service
  • 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

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

Challenge Tasks

  1. Create a console application named TipCalculator-LastName
  2. Complete the following tasks:
    • Prompt the user to enter the bill subtotal.
    • Prompt the user to enter the tip percentage as a whole number. For example, 20 means 20%.
    • Calculate the tip amount.
    • Formula: Tip = Subtotal × (TipPercentage ÷ 100)
    • Calculate the total amount.
    • Display the calculated tip amount and total amount to the user in a clear and formatted manner.
    • If you want to ensure your dollar amount always has two decimal places, google search how to accomplish this with your respective programming language.
      • Example: Search 'Add leading zeroes to double in C#'

Sample Output

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