pjcode0's blog

By pjcode0, history, 19 months ago, In English

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

  • Vote: I like it
  • -3
  • Vote: I do not like it

»
19 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    19 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Thankyou, vgtcross. I got the concept.