CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Join Date
    May 2004
    Posts
    249

    Re: Function - Help!!!

    Just asking for one last help

    Assuming that the vending machine starts every morning with a fixed number of coins (10) of each denomination. If the vending machine has run out of a particular coin, then alternate means for giving change must be found.

    So how could i go about that

  2. #17
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Function - Help!!!

    Quote Originally Posted by rockx View Post
    Just asking for one last help

    Assuming that the vending machine starts every morning with a fixed number of coins (10) of each denomination. If the vending machine has run out of a particular coin, then alternate means for giving change must be found.

    So how could i go about that
    By writing functions to do these things.
    Code:
    if ( NumberOfCoinsInMachine() == 0 )
    {
       PerformAlternateMeans();
    }
    Regards,

    Paul McKenzie

  3. #18
    Join Date
    May 2004
    Posts
    249

    Re: Function - Help!!!

    so for that piece of code, do i need to use a double array or should i declare a totally new single array to contain all the coins.

  4. #19
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Function - Help!!!

    Quote Originally Posted by rockx View Post
    so for that piece of code, do i need to use a double array or should i declare a totally new single array to contain all the coins.
    The last thing you should be thinking of is "arrays" or anything C++. The first thing as 2kaud stated is to lay out the design and not just write code.

    What you need is to create a VendingMachine class. That is what everyone helping you would have done to begin with. Then all of these requirements would be encapsulated within this class. I would even state that this is what your next step should be (create a class). Trying to make changes to your current program just leads to code that is going to be more messy and cluttered, and will not add to learning how to organize and write a proper C++ program.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; August 17th, 2013 at 11:49 PM.

  5. #20
    Join Date
    Aug 2013
    Location
    Dallas, TX
    Posts
    2

    Re: Function - Help!!!

    Quote Originally Posted by 2kaud View Post
    Again, how would you do this manually? What would be the algorithm to use? I'll give you a big hint here. This question has already been asked and answered on these forums a few months ago!
    Ooh snap!!

  6. #21
    Join Date
    May 2004
    Posts
    249

    Re: Function - Help!!!

    Would it be fun if this entire program could be done using vectors?????

  7. #22
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Function - Help!!!

    No.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured