I have problem in exexcuting the code for 3rd case

This is the problem which i want to solve as If price is less than 500, fess will be 1.5%, above 500 it will be 3%. and will increase by 0.5% for every multiple of 500 and max fee chargable is 18%.

// example:- if amount is 200 fees will be 1.5%of 200 and price to be paid will be 200+ fees
// if amount is greater than 500 and less than 1000 fess will 3% of the amount
// if amount is greater than 1000 and less than 1500 fees will be 3.5%.

Test Cases:->

1.If the amount is less than 500 it will charge 1.5%
2.if the amount is greater than 500 and less than 1000 it will charge 3%.
3. and then main test case arise if the amount is greater than 1000 means after 1000
it will start increasing the charge by 0.5% as increase in amount by 500 till last when
we reach the charge of 18% for the specific amount.

Amount Charge
0000-0500 1.5
0500-1000 3.0
1000-1500 3.5
1500-2000 4.0
2000-2500 4.5
3000-3500 5.0
3500-4000 5.5
4000-4500 6.0
4500-5000 6.5
6000-6500 7.0
6500-7000 7.5
7000-7500 8.0
8000-8500 8.5
8500-9000 9.0
9000-9500 9.5
9500-10000 10.0
10000-10500 10.5
10500-11000 11.0
11500-13000 11.5
13500-14000 12.0
and so on as max charge is 18 %

var fees=700;
var temp=fees;

if(temp<500){
   total=fees+fees*(15/1000);
   console.log(total);
}
else if(temp>500 &&temp<1000){
    total=fees+fees*(30/1000);
    console.log(total);
}

what kind of help do you need?

i don’t know what condition i will use for the 3rd case as mentioned in the question

every 500 the charge increases by 0.5%, you can manually do all of the ranges, or you could use some maths, depending on how much you are confortable with that

I am looking for loop and condition for the condition even i can write program with specific ranges and that makes the program so Complex so thats why i am asking u Will you help me.

What have you tried to satisfy the third condition?

I am thinking a lot but i am not getting what condition meets the Third Case.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.