my program works as far as asking the user to enter the money and keeping count of the money enter. but once enough money is entered to purchase an item the program doesnt respond to ask the user to enter a selection. can anyoe assist me please?
after i enter "e" to end the depositing of the money, the program then asks the user to enter a selection. i enter a selection and the program ends and it not suppose to do that. im not sure how to get the program to run thru the rest of the code. im not sure what i have done wrong in the last codes of if else statements after the selection is entered by the user.
Oh, I see, I thought you meant it wasn't getting to the part where it asks for the item.
Just from looking over it I'm thinking it's a problem with your brackets. I'll give it a real look-over though.
!
I'm an idiot.
The "Item" is an "int" rather than a string.
Try it with a string and it should be fine.
Also, your program would be a lot easier to read if you used switch-case instead of if statements. It's really easy to learn and looks very professional. :D
you know i was told switch statments were harder because you have to add the break that was by my own teacher. makes me think she didnt think i could learn it
For the purpose of a class assignment it's probably a lot easier to just leave it as an int, and change the choices from "C1" and "C2" to just "1" and "2" in the if statements.
I'm sorry, I'm being really hasty in my responses, I've missed something else that was actually what was causing all your problems. At the top you've defined "C1" and all those to all equal 0. So the only way to get your program to work properly is to choose 0 as the item number. But then you buy everything. :P
So:
int c1=0, c2=0, c3=0, c4=0, c5=0, c6=0;
int C1=0, C2=0, C3=0, C4=0, C5=0, C6=0;
should be
int c1=1, c2=2, c3=3, c4=4, c5=5, c6=6;
int C1=1, C2=2, C3=3, C4=4, C5=5, C6=6;
Then you just have a little syntax issue to work out, but if I told you how to fix that it'd be cheating!
Just organize your code, or surprise your teacher and use a switch statement.