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

what's the problem with this program? http://dpaste.com/911626/

OpenStudy (microbot):

one quick hint: your outstandingbalance is created after the for loop...so it doesnt know how much that is till it finisces the for loop....(after 12 rounds) your implementation is all wrong i believe... u define your function (main) but u call it after the spot u actually need it..... try calling it before the for loop and see what happens...

OpenStudy (microbot):

plus: in the end you are printing the word "RESULT" why?!

OpenStudy (rsmith6559):

I would recommend one or two blank lines to separate your function from your main code. That will give a much different perspective on what the program is really doing. During debugging, I frequently print the value of variables at different points to try to find the problem, and then take the print statements out when it starts running.

OpenStudy (harsimran_hs4):

hey here are some suggestions 1. you don`t actually need a main() function because what you are doing is taking i as an argument and returning it back besides taking some inputs so rather don`t use main() or do all your calculations in the main() itself. 2. as pointed out do separate your functions from the other code 3. just printing RESULT on the screen won`t do rather print in the more information that is required as an output 4. as a good programming practice try and name your functions that are easy to understand just by reading the name e.g you could name it balance() or card_balance something of this sort. 5. at this stage your best debugging tool is print statements. if you don`t get your answer try introducing print statements to check what you expected and what you got back from the machine.

OpenStudy (anonymous):

thank you all for the responses

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!