Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

shiroo

  • one year ago

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

  • This Question is Closed
  1. MicroBot
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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...

  2. MicroBot
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  3. rsmith6559
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. harsimran_hs4
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

  5. shiroo
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thank you all for the responses

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

    Search OpenStudy
    • Attachments:

Ask your own question

Ask a Question
Find 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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.