-
August 17th, 2013, 10:59 PM
#16
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
-
August 17th, 2013, 11:07 PM
#17
Re: Function - Help!!!
Originally Posted by rockx
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
-
August 17th, 2013, 11:15 PM
#18
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.
-
August 17th, 2013, 11:33 PM
#19
Re: Function - Help!!!
Originally Posted by rockx
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.
-
August 18th, 2013, 02:28 AM
#20
Re: Function - Help!!!
Originally Posted by 2kaud
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!!
-
September 17th, 2013, 10:22 PM
#21
Re: Function - Help!!!
Would it be fun if this entire program could be done using vectors?????
-
September 17th, 2013, 10:52 PM
#22
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|