Блог пользователя pjcode0

Автор pjcode0, история, 20 месяцев назад, По-английски

Write a program to input gross amount of bill and calculate the net amount according to the below discounts:

If amount <= 1000, then discount is 0% If amount is from 1001 to 5000, then discount is 5% If amount is from 5001 to 10000, then discount is 10% If amount > 10000, then discount is 15% An additional discount of 2% if bill is greater than 30000.

input : 2500 output: 2375.00 can anyone help . i know it is a simple program but i am not getting it idk why i have tries net amount = gross_amount divided by 1.05 (if gross amount from 1001 to 5000) , similarly gross_amount divided by 1.07 if it is from 5001 to 10000, .... but it is giving wrong result.

Some other test cases:

input: 500 output: 500.0

input: 25000 output: 21250.0

input: 5500 output: 4950.0

input: 12000 output: 10200.0

input: 40000 output: 33200.0

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
20 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

You don't divide by $$$(1 + \frac{discount}{100})$$$, you need to multiply by $$$(1 - \frac{discount}{100})$$$. You should probably study more about percentage calculations if this feels hard to you.