locked
Help with codes...

    Question

  • I'm working on a problem that states: Write a program to make change for an amount of money 0 through 99 cents input by the user. The output of the program should show the number of coins from each denomination used to make change.

    I've already created my form, I'm just unsure of what codes to use to make the program run efficiently. Can anyone help?

    Sunday, September 25, 2011 8:38 PM

Answers

All replies

  • I suggest you start by thinking of you you would make change in the real world, then try to write code that does the same thing. If you have to give someone 88 cents in change, how many quarters would you need? How did you come up with that number (try to think of a general method rather than one that only works for 88 cents)? Next, how would you decide how many dimes.
    Sunday, September 25, 2011 8:58 PM
  • Is this a school-related question?
    First write out an algorythm on paper. try this a few times till you come at something that looks right, next translate this in coding, it might take a few times but you'll find it eventually.

    Regards,

    Dylan Meeus


    0x2B |~ 0x2B Blog : www.it-ca.net/blogdylan
    Sunday, September 25, 2011 9:20 PM
  • I'm working on a problem that states: Write a program to make change for an amount of money 0 through 99 cents input by the user. The output of the program should show the number of coins from each denomination used to make change.

    I've already created my form, I'm just unsure of what codes to use to make the program run efficiently. Can anyone help?

    Hi,

    You could take a look at my code in this thread:>>

    http://social.msdn.microsoft.com/Forums/en/vblanguage/thread/ee1e001c-c802-4a9d-a79f-fd955724b0e6

    it has code which would show you the change given a certain amount.

     

    You could maybe adapt that code to suit your question here.  :)

     




    Regards,

    profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers

    Click this link to see the NEW way of how to insert a picture into a forum post.

    Installing VB6 on Windows 7

    App Hub for Windows Phone & XBOX 360 developers.

    Monday, September 26, 2011 12:18 AM
  • I agree with the gents above. This sounds like a school problem, and while there aren't rules against helping with school projects (not on the forums anyway, rules from your teacher? That's another story...) it would probably be best for you to work things out yourself.

    As others said, try to reason through it. In the real world, you would start with the biggest coin and work your way down to the smaller ones. How many quarters can I give without going over the amount? Okay, now how many dimes can I give? Okay, now nickles, and pennies. Good luck!

    Monday, September 26, 2011 5:19 PM