Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 21 Online
OpenStudy (anonymous):

In the solution for ps1c, I kind of feel like there is some cheating going on. Here is the code for the solution for ps1c: http://dpaste.com/1152582/ In line 33, whoever created this solution is adding to the payment a fraction of a cent to bump up the total monthly payment. My code is pretty identical to this, but I didn't add this fraction of a cent, I used an extra condition to get close to what the answer is on the handout. I guess my question is does anyone else think the solution for the problem is kind of cheating by adding that fraction of a cent?

OpenStudy (anonymous):

I don't think i would call it cheating. Does it work? Why did they do that, what does it achieve? hmmm looks like they want to force it to round up which is ok, it ensures that the answer will pay off the loan in 12 months. It looks like a strategy to mitigate rounding errors. some comments would have been nice.

OpenStudy (anonymous):

oh wait, there is a comment - my bad

OpenStudy (anonymous):

I guess when you put it like that, it makes more sense. I was coming at it from an angle of just having the code go through one more iteration to finally pay off the loan (if that makes sense). I got it to work, it's just my final answers were a few cents off from what the handout has. Were I to round up, I would get the same exact answer. I guess I was just thinking, why would any credit card company round up??

OpenStudy (anonymous):

a credit card company might not but if you wanted to pay it off in a fixed time period that is different than the loan originator wants, you might want to. - you have to decide when to stop iterating - it looks to me like the tolerance is 0.005 dollars between high and low. at line 33 that criteria has been reached but the answer may be in fractions of a cent and if the round function rounds down, the solution may not meet the specification that the anwer apy off the loan in 12 months.

OpenStudy (anonymous):

You have to round up to meet the specifications given by the problem set. The minimum monthly payment is exactly that, you can not pay any less, even by a fraction of a cent. Since there is no way to pay a fraction of a cent, you have no choice but to round up to the next highest increment you can actually pay.

OpenStudy (anonymous):

tmargules, that's a great explanation. Thanks!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!