I am making a very simple so to say "Soda Machine". I want it to ask the user if they would like a free soda, if they say yes it will keep going on with the program and if they say no it will just end the program or maybe say thank have a nice day. I have it written out to where it says welcome to the soda machine and then gives them the 5 choices. Then it asks which one they want and you are able to enter whatever you would like and then it simply prints out what you chose.
What I want it to do like I said was to ask if they want one or not. If they say yes keeps going on and if no stops.
I am a little stuck on how to make that happen. I would think I need to use an IF and ELSE statement but not really sure how to implement them into the program. Any help is great!
Thanks. :)
Oh and also if there is anything I should change please let me know!
And also if anyone knows how to make it so that they are only able to select one of the 5 ones that are listed and not just type anything random in and if they were to, it could maybe respond that is not one of the 5 beverages.
you would only use one if statement just like in my code below and i use do while loop so they will only able to select one of the choices if they choose one that is not listed in choices they will be asked again to choose.
PS:
You don't need to do this: cout<<"You picked:"<<" "<<mystr;
You can just do this: cout<<"You picked: "<<mystr
And for a char, you don't use "", you use ''. You use "" for strings. Except the program will still work fine, it's just a good habit.