I have the following problem in writing my Java app. I have to increase the rate of the discount after entering the turnover for the previous month.
The gold card comes with an initial discount rate of 2%. The discount rate grows 1% for each $100 from the turnover, capping at 10%.
For example :
If I enter 100$ - the growth rate is going to be 1% added to the initial discount rate of 2%.
If I enter 300$ - the growth rate is going to be 3% added to the initial discount rate of 2$.
If I enter 1000$ - the growth rate is going to be 10% added to the initial discount rate of 2%.
If I enter 1500$ - the growth rate is going to be 10% added to the initial discount rate of 2%.
How would you solve this problem?
EDIT : I want to avoid switch statement and do it with a for loop instead.
Aucun commentaire:
Enregistrer un commentaire