anonymous
  • anonymous
I've almost got it, but it seems the 1st month lists the initial balance and then has the correct balance for the month 2 which should be in month 1. I tried if/else statements here to correct but I can't quite seem to correct it. (I know the ending balances are off by that last amount.) Please help??? Thank you. http://pastebin.com/xggRFm0N
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
It would help if you would post your code instead of just your results, but if what you say is true, that it's giving the wrong value for the first month and then the correct value after that, then I would guess your print statement is somehow in the "wrong" place so that it prints the balance before calculating the first month, but then it calculates the second (and subsequent) months before it prints the balance. This would likely have to do with the fact that for the first month you just entered a loop, but for the subsequent months you are already in the loop, thus the different behavior. But, it would help to see it.
anonymous
  • anonymous
How much code can I print w/o showing all it? We're not supposed to... if month == 0: PreviousBalance = balance - MinimumMonthlyPayment else: PreviousBalance = MonthlyUnpaidBalance + (annualInterestRate/12.0 * MonthlyUnpaidBalance) ... I think this is where I get stuck w/ my code. HEre's a little more: ... print 'PreviousBalance: ' +str(round(PreviousBalance,2)) is inside the loop. *Thanks* for any help you can give!!! =)
anonymous
  • anonymous
PS - The 1st month prints the original starting balance and the 2nd month shows the correct balance. I declared month = 0 and my loop is: for month in range(12):..... I've tried changing my loop in case that was wrong but it seems to be ok; I also tried changing month = 1, but it doesn't seem to matter as it still outputs the same thing.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
are you not supposed to share code? oh. i didnt know that. because i'm not technically enrolled in the class but it seemed like he said in the first lecture people could collaborate all they want. but maybe that's only for the students there at MIT. so...i guess i should stop posting so much code. i wouldn't want them to be mad at me since they are so kind as to make all this available. But it's real hard to say without seeing it. If you get the correct second month, obviously you calculated the correct first month. If you're not printing the right first month, you must be printing before you are done calculating...that's all I can think of. One thing you could do is put a "print variable" statement in the code after every time you change a variable...just to see what the variables are at each point in time. Then, if something isn't what you expect, you will know at what point it happened. You can take them out later when you figure it out.
anonymous
  • anonymous
Oh.... this is a problem set & we can collaborate but not share code. Well, I didn't calc the 1st month; it somehow pulled the orig balance which I declared at the top. I did that - dumped all the vars so I could see what was going on but it's just one month off and driving me crazy! I've rewritten most of the code and it gives me crazy wrong answers so this is the best iteration of code, just a wrong month for one of the variables.... will keep plugging away.... Thx!
anonymous
  • anonymous
if you can see that there are too many or too few iterations, then you are not initializing a variable correctly or the conditional expression you are using to stop iteration is wrong.
anonymous
  • anonymous
My loop is this: for month in range(12) and I initialized it w/ month = 0. This runs through a dozen times which is fine and I don't seem to have any errors that way. The condition is just met by the range. Perhaps I should use a different kind of for loop? I think it's ok to start with month 0 as long as my answers are printed correctly for the checker. I've been trying everything and I just can't seem to get it to shift to the right answer without breaking all of my code to wrong answers (I've tried a zillion different ways and this had the most accurate answers, just in the wrong place). I'm still stuck....
anonymous
  • anonymous
post your code to a code pasting site :)
anonymous
  • anonymous
We aren't allowed to post code, but I have a similar question. My results are: http://pastebin.com/4LTZxGHX and I need loop help please. I need to get rid of the first month and then all should be perfect. I used: for month in range(13): which should work but how do I exclude that first month? I tried several ways and different loops. Any help would be GREATLY appreciated!!!
anonymous
  • anonymous
k8oconnor, we really want to help! it's hard without being able to see, but if that's the rules...ok then i guess. i reread your first post. you are saying the starting balance for month 2 should be the starting balance for month 1? if so, im almost sure you are doing something like this: startingbalance = int(raw_input('enter your starting balance.') (your loop, such as while or for, either can work) print startingbalance modify startingbalance (by adding interest and deducting payment) and the loop continues until your end condition. from here, it doesn't APPEAR your loop is the problem (it begins and ends OK and is doing the right things overall). It APPEARS you are printing startingbalance the first time without modifying it. you need to modify it before you print it. but, this is just a guess, since i can't really see. Feeling quite useless, actually...
anonymous
  • anonymous
I sincerely appreciate you trying to help me. I missed the deadline. I conversed w/ the staff. My loop was right: for month in (1,13) - I just had 13 but that's ok, and everything was right (I think this was not the final iteration of my code after we chatted here), but I couldn't get rid of that first iteration. Ah well, maybe they'll post the answer so we can see what should have been. Thanks again for trying! on to the next assignment! =)
anonymous
  • anonymous
if the deadline is over, post your code. which problem is it? minimum payment to pay off a debt or determine total paid and remaining balance?
anonymous
  • anonymous
#1 - Determine total paid and remaining balance. No thx. May use it for next session, and mine wasn't perfect anyhow.

Looking for something else?

Not the answer you are looking for? Search for more explanations.