A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 one year ago
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
 one year ago
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

This Question is Open

RCMorea
 one year ago
Best ResponseYou've already chosen the best response.1It 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.

k8oconnor
 one year ago
Best ResponseYou've already chosen the best response.0How 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!!! =)

k8oconnor
 one year ago
Best ResponseYou've already chosen the best response.0PS  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.

RCMorea
 one year ago
Best ResponseYou've already chosen the best response.1are 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.

k8oconnor
 one year ago
Best ResponseYou've already chosen the best response.0Oh.... 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!

bwCA
 one year ago
Best ResponseYou've already chosen the best response.0if 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.

k8oconnor
 one year ago
Best ResponseYou've already chosen the best response.0My 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....

bwCA
 one year ago
Best ResponseYou've already chosen the best response.0post your code to a code pasting site :)

k8oconnor
 one year ago
Best ResponseYou've already chosen the best response.0We 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!!!

RCMorea
 one year ago
Best ResponseYou've already chosen the best response.1k8oconnor, 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...

k8oconnor
 one year ago
Best ResponseYou've already chosen the best response.0I 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! =)

bwCA
 one year ago
Best ResponseYou've already chosen the best response.0if 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?

k8oconnor
 one year ago
Best ResponseYou've already chosen the best response.0#1  Determine total paid and remaining balance. No thx. May use it for next session, and mine wasn't perfect anyhow.
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.