Kotlinlearncs.online LogoJava
Return to List

Solve: Discount Calculator 1

Created By: Justin Maier
/ Version: 2024.7.0

An online shopping platform is having a sale and offering customers a discount depending on how much they spend. The discount levels are listed below. Customers are given the highest discount level that they qualify for (they never receive multiple discount levels).

  • Spend $200 or more: 20% off
  • Spend $100 or more: 10% off
  • Spend $50 or more: 5% off

You are given a double variable subtotal that represents a customer's purchase total before applying the discount. You should calculate the customer's final total after applying the discount and store it in an double variable named finalTotal that you will need to declare. Fractional cents are okay; do not worry about restricting your answer to two decimal places.

Related Lessons

Stuck? You may find these lessons helpful: