Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
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%.

See the 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 %

What I have tried:

var val=1499;
temp=val;
var tax=1.5;
if(val>=500){  
    tax=3.0;
    temp=temp-500;1601 
    while(temp>=500)
    {
        if(tax==18){
            break;
        }
        tax=tax+0.5;
        temp=temp-500;
    }
   
}
console.log(`Total tax on ${val}= ${tax} %`)
tax=val*tax/100
var total=val+tax;
console.log(`Total Value After Tax is = ${total}`);
Posted
Updated 13-Aug-21 2:49am
v3
Comments
Richard MacCutchan 12-Aug-21 7:31am    
This is simple mathematics. Get the amount above 1000 and divide it by 500 to find the multiple of 0.5 to add to the fees. Check that it is not greater than 18.
[no name] 12-Aug-21 7:34am    
Can u write the COde for me as I am not understanding it.
Richard MacCutchan 12-Aug-21 8:00am    
See below. The value returned needs to be divided by 10 for the final calculation.

The logic is something like:
JavaScript
function calculate(amount) {
  var fees = 0;
  if (amount > 500) {
    fees = 30;
    var temp = amount - 500;
    if (temp > 0) {
      var mult = temp / 500;
      mult = mult * 5;
      if (mult > 180) {
        mult = 180;
      }
      fees = fees + mult;
    }
  }
  else {
    fees = 15;
  }
  return fees;
}
 
Share this answer
 
Comments
[no name] 12-Aug-21 8:15am    
Read the question carefully you are not getting it is like tax system and i don't want to get the multiple of 0.5. Please read Carefully even i have explain more precisely with test Cases.
Richard MacCutchan 12-Aug-21 9:35am    
That is just a rough example of the required calculation. You need to tidy it up yourself
[no name] 13-Aug-21 14:44pm    
even i know u don't know the solution u are just sh*tty person and don't want to say anything. i have made it by my own and u r just really creaps holy sh*t
OriginalGriff 13-Aug-21 14:55pm    
That puts him on the list ... :sigh:
Richard MacCutchan 13-Aug-21 15:05pm    
Someone else who is likely to go far.
Quote:
Can u write the COde for me as I am not understanding it.


While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Comments
[no name] 13-Aug-21 14:41pm    
Hello Just listen i was Struck so that's why asked the question. if u don't want to help just don't these give sh*tty type of solutions. U are really a that kind of person what i don't want to say.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900