To start with, rather than your hard-coded '10' on line 19, you'll need separate variables to keep track of the current quantity of each type of drink.
1 2 3
int currentAmountCoke = 10;
int currentAmountPepsi = 10;
int currentAmountSprite = 10;
and when a selection is made decrement the appropriate one.
e.g.
I can see that you have a few problems to use our suggestions. So I wrote this code for you today. All you have to to is to read this code and try to understand what I did.
If you still have questions about the code, please ask!
Line 98: while ((currentAmountCoke <= 10) || (currentAmountPepsi <= 10) || (currentAmountSprite <= 10))
looks like infinite loop.
Maybe while ((currentAmountCoke > 10) || (currentAmountPepsi > 10) || (currentAmountSprite > 10))
be better.
Only 168 lines for this code? Looser.
OK... I don't really understand what's the problem here ;)
When I ask for -1 it says "Insufficient can of drink, please [...]"
That's what the (quantity > 0) for :D
And please don't call me loser.
I tried to make a simple code (OK, it's a little bit longer than expected), but I think
this works pretty well.
And if there's a mistake, as you said, please give constructive feedback.
hey thanks ANproCUBE for your speedy reply. I manage to understand the coding somehow, although your coding are still a little advance to me. Thanks a lot.