|
Answer» hey guyz im trying to make an 'if' statement and im experiencing problems this is my CODE so far;
if (choice == 1); cout << "You picked Gum! \n Now ENTER what brand of Gum you want \n 1. Hubba Bubba \n 2. Extra \n 3. Juicy Fruits" << endl; cin >> choice;
if (choice == 1); cout << "You have bought Hubba Bubba! \n Please pay: $" << Hubba_Bubba << endl;
if (choice == 2); cout << "You have bought Extra! \n Please pay: $" << Extra << endl;
then when i run program and enter choice 2, i get choice 1 showing on programing stating the cout statement that i bought choice 1 when i picked 2, followed by choice 2
what i want is to somehow not show choice 1 if 2 is selected, i was thinking of using 'void' but im not surehow to incorporate it.
also i havent defined choice 2, im hoping that by using cin >> choice , any 'int' entered can be recalled by using if (choice == '?') am i on the right track? because i got alot more codes to write :s
thanksok guyz dont worry that was really dumb of me haha i fixed it, for others wondering it was a ';' problem
problem
if (choice == 1); cout << "You picked Gum! \n Now enter what brand of Gum you want \n 1. Hubba Bubba \n 2. Extra \n 3. Juicy Fruits" << endl; cin >> choice;
if (choice == 1); cout << "You have bought Hubba Bubba! \n Please pay: $" << Hubba_Bubba << endl; if (choice == 2); cout << "You have bought Extra! \n Please pay: $" << Extra << endl;
solution
if (choice == 1) cout << "You picked Gum! \n Now enter what brand of Gum you want \n 1. Hubba Bubba \n 2. Extra \n 3. Juicy Fruits" << endl; cin >> choice;
if (choice == 1) cout << "You have bought Hubba Bubba! \n Please pay: $" << Hubba_Bubba << endl; if (choice == 2) cout << "You have bought Extra! \n Please pay: $" << Extra << endl;
LOL sorry for wasting post, but it took me like 3 HOURS to figure this little problem out :s haha have you TRIED switch instead of laddered Ifs?Not sure how to use a switch, can you give me an example please???
thankswoops- never mind- switch wouldn't be much cleaner then what you have now, since your not really choosing from a wide variety of options- just 1 for gum and a few options below it? or is this gum selection stuff just a small part of the number of choices?
I dont have idea about ur problem pls ask any computer experts about ur problem!!!!!!!!!! Quote from: garydeen on September 09, 2008, 06:21:13 AM I dont have idea about ur problem pls ask any computer experts about ur problem!!!!!!!!!!
the problem was solved. Your post is the equivalent of putting your hand up in class and answering "I don't know". If you don't have something meaningful to add, don't add anything.Quote from: BC_Programmer on September 09, 2008, 02:04:31 PMQuote from: garydeen on September 09, 2008, 06:21:13 AMI dont have idea about ur problem pls ask any computer experts about ur problem!!!!!!!!!!
the problem was solved. Your post is the equivalent of putting your hand up in class and answering "I don't know". If you don't have something meaningful to add, don't add anything.
It's like putting your hand up in class and answering "I don't know" after the answer has been given and eleven days later! lolQuote from: fireballs on September 09, 2008, 03:53:03 PMQuote from: BC_Programmer on September 09, 2008, 02:04:31 PMQuote from: garydeen on September 09, 2008, 06:21:13 AMI dont have idea about ur problem pls ask any computer experts about ur problem!!!!!!!!!!
the problem was solved. Your post is the equivalent of putting your hand up in class and answering "I don't know". If you don't have something meaningful to add, don't add anything.
It's like putting your hand up in class and answering "I don't know" after the answer has been given and eleven days later! lol
not something people would consider behaviour of a BRIGHT student... Is this the same fellow that made a similar post in the batch programs thread?Quote from: BC_Programmer on September 09, 2008, 09:44:21 PMQuote from: fireballs on September 09, 2008, 03:53:03 PMQuote from: BC_Programmer on September 09, 2008, 02:04:31 PMQuote from: garydeen on September 09, 2008, 06:21:13 AMI dont have idea about ur problem pls ask any computer experts about ur problem!!!!!!!!!!
the problem was solved. Your post is the equivalent of putting your hand up in class and answering "I don't know". If you don't have something meaningful to add, don't add anything.
It's like putting your hand up in class and answering "I don't know" after the answer has been given and eleven days later! lol
not something people would consider behaviour of a bright student... Is this the same fellow that made a similar post in the batch programs thread?
Who knows and who cares....
|