Problem 35 Savings Calculator

Back to General discussions forum

tinoymathews     2020-03-31 18:35:31

I think the checker has a problem for inputs where, the principal is below 100, the total final amount is less than 1000 and the interest rate is 1%

Rodion (admin)     2020-04-02 23:11:46
User avatar

Hi Friend! Sorry, but after thinking a bit, I'm not sure what exactly problem do you mean. Could you please provide specific test case - input data, wrong and correct answer?

tinoymathews     2020-04-03 13:03:56

Hi,

Under below conditions:

Case : Principal : 50, Target Amount : 1000, Rate of Interest : 1

Checker Answer: 303 My answer: 302

For every other case my answer matches with the checker. I solved the Mortgage Calculator already before this, but I cannot figure out where I am going wrong or if the checker is wrong.

Please advice.

Thanks and Regards, Tinoy Mathews

Rodion (admin)     2020-04-04 11:17:40
User avatar

Hi there!

I haven't checked yet, but it seems your code slightly deviates from what problem asks:

round( xFinalAmount + ( xFinalAmount*xRate )/100, 2 )

this is not round down but round to nearest. While we want rounding down (as banks generally do).

tinoymathews     2020-04-04 14:29:01

Hi,

My mistake acknowledged. Will make a correction there.

Regards, Tinoy Mathews

Please login and solve 5 problems to be able to post at forum