C++ vending machine

WriteCreate a program that simulates a vending machine. The vending machine offers three products: Soda, Juice, and Water Bottles. Soda costs P30, juice costs P23, and water bottle costs P15. Create menu that asks for the user's choice and exits when the user inputs 555. Once a choice has been made, create a loop that would repeatedly ask for coins to be inserted until the appropriate price is reached or exceeded. The vending machine program should accept coin denominations of one, five and ten and accepts bill denominations of twenty and fifty only. In the end, after the cost was accumulated or exceeded, the program should display a message of purchase completion along with any change that might be returned. Only WHILE LOOP, SWITCH CASE and IF ELSE please.

Last edited on
Perhaps you should plan out what your program is going to be doing. It's going to be simulating a vending machine, so a menu based screen where the user selects options would be somewhat ideal.

1
2
3
4
5
6
7
8
9
10
11
12
int main()
{
  bool userAtVendingMachine = true;
  while(userAtVendingMachine)
  {
     if(user wants to do this)
       doThis()
     if(user wants to do that)
       dothat();
  }
  return 0;
}
Topic archived. No new replies allowed.