So here is the question:
Suppose you transfer $N and bank's charge occurs as follows:
Cost is $10, if N ≤500
Cost is $10+2% of N, if 500 < N < 1000
Cost is $10 + 1% of N, if 1000 ≤ N ≤ 3000
Maximum cost is 40$.
There is a problem at the last part " else if (N>=1000 && N<=3000) sum=19.98+(1*(N-999)/100); " when i run the program and i give the value of 2000 the output is not 33.00. So the mistake is at calculating the sum of 2000$ but I can't figure it out exactly..can you help me?
N>=1 && N<=10000;
What is that line supposed to do. Hint: It doesn't do anything.
sum=10+(2*(N-500)/100);
That doesn't represent the calculation as stated in the problem statement.
sum=19.98+(1*(N-999)/100);
Ditto.
PLEASE USE CODE TAGS (the <> formatting button) when posting code. http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Hint: You can edit your previous post, highlight your code and press the <> formatting button.
actually yeah the first line its the limit of N because if the input would be more than 10000 then it shouldnt print anything.
did you even try to give examples? because if i would do the calculations exactly as the problem required than the answer wouldn't be 33.00 for 2000$.
actually yeah the first line its the limit of N because if the input would be more than 10000 then it shouldnt print anything.
Line 5: How does it not print anything? That is not an if statement. As I said before, that statement does nothing. The rest of the program will execute regardless of the value of N.
did you even try to give examples? because if i would do the calculations exactly as the problem required than the answer wouldn't be 33.00 for 2000$.
Line 9: You're not reading the instructions correctly. Why are you subtracting 500 from N before taking 2%? The instructions say nothing about subtracting 500 first.
Line 10: Why are you setting the fixed cost to 19.99? The instructions say for over $1000 the fixed cost is $10. And again, why are you subtracting 999 from N? The instructions say nothing about that.
Line 11: You have no code for the case where N > $3000 and less than $10000 (i.e. limit is $40).
When I do this on a calculator, I get 2000 * 1% = $20 + $10 = $30. I don't agree that the correct answer is $33.