I'm doing exercises in my intro to C++ book and I am a little baffled as to why the code is supposed to be the way it is.
I did the example my way and the example data entered produced different results then the books example data results.
So I rewrote it the books way and it works but they don't provide an explanation as to why and I can't find anything on google.
The part that confuses me is this line:
monthlyRate = interestRate / 1200;
At first I had it as monthlyRate = interestRate / 12;
But that produced bad results.
Why does it have to be 1200 instead of 12 ?
I am guessing you are supposed to enter in the interestRate as a percentage, so the program divides by 1200 to account for both the number of months and the percentage. (Remember n% ~ n/100)
Later on, the program uses monthlyRate in some calculations, so having the decimal form and not the percentage is important.