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

Problem set 1, part b, I have the code almost exactly the same as the solution. The problem I am running into is that my Print commands at the end are orange when the solution has them as purple. The code is not printing anything aside from the two initial inputs. I have changed the indentation numerous time to no avail. Can anyone help me with this?

OpenStudy (anonymous):

Likely some minor issue, upload your code to http://pastebin.com/ or similar and we can likely spot the issue.

OpenStudy (anonymous):

Uploaded to pastebin.com under theode44. I can get the print command to turn purple if I indent them but then the code goes into an infinite loop.

OpenStudy (anonymous):

post the link to your paste

OpenStudy (anonymous):

The print shows up fine for me but I found 2 (maybe 3) issues 1. monthlyRate should be divided 100 to get percentage 2. the first while should be postBalance and not balance 3. you may need to do "postBalance -= minPayment" before calculating "interest" depending if the interest should be applied before or after making a payment.

OpenStudy (anonymous):

Oh, and here's is the link of what I looked at http://pastebin.com/4yKeTDaH

OpenStudy (anonymous):

Here is the solution from MIT. It seems to be almost verbatim to mine: http://pastebin.com/U9DzSF2w

OpenStudy (anonymous):

does your condition at line 11 make sense? is that the correct variable?

OpenStudy (anonymous):

That one says to enter the interest rate as a decimal, so if you enter as 0.07 instead of 7 then you would not have to divide by 100 as in my first comment and since they calculate the interest prior to the payment then 3 is not an issue either, Which leaves #2 as bwCA also stated.

OpenStudy (anonymous):

Thanks guys! It was #2 that was the issue.

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!