Here is the problem: Here is the problem text: You have invented a vending machine capable of deep frying twinkies. Write a program to simulate the vending machine. It costs $ 3.50 to buy a deep- fried twinkie, and the machine only takes coins in denominations of a dollar, quarter, dime, or nickel. Write code to simulate a person putting money into the vending machine by repeatedly prompting the user for the next coin to be inserted. Output the total entered so far when each coin is inserted. When $ 3.50 or more is added, the program should output Enjoy your deep- fried twinkie along with any change that should be returned.
Hi there, So far everything is working fine except one minor thing. The prompt "you have to enter this amount more" still appears even if the machine owes money.
Ok, you have multiple problems first the one you asked about. The problem with it outputting "you have to enter this amount more" is because your while statement will output that as long as your total is greater than 1. I will let you figure out how to fix that.
Second, don't use global variables! Unless there constant, don't use them. Pass variables to the function and have it return them or use reference variables.
OK here is what I changed your code to. I tried to keep it as close to yours as I could but I did end up haveing to change multiple things. Take a look and hopefully, it helps you solve your problem.