Hello Notanormie,
you wrote: |
---|
I feel my question wasnt answered. |
The answer is 42.
https://www.youtube.com/watch?v=aboZctrHfK8
Your question has been answered. The problem is that either you are not listing or there is something that you do not understand correctly.
Given your code:
1 2 3 4 5 6 7 8 9 10
|
string Ham = "Ham";
string Veggie = " Veggie";
string Rat = " Rat";
string Bacon = " Bacon";
string Hair = " Hair";
cout << "What type of sandwich do you want?\n"; // <--- "sandwhich" is misspelled. "sandwich" is correct. I expect it is a language problem. No worries.
cin >> Ham, Veggie, Rat;
if (Ham == "Ham")
|
Exactly what do you expect line 8 to do?
AbstractionAnon has already commented on the use of the (,)s. When I tested your code only "Ham" received a new value from the "cin" Which means that the following if statement will never be true unless you actually did enter "Ham". A 1 in 3 chance there.
Since the value of the variable "Rat" has not changed that if statement will be true, but that may not be what is wanted.
When you present a menu to choose from the variable that you need to use would be "choice" or "menuChoice" anything but a variable that is initialized to a value and should be a constant variable.
If you had put "const" in front of the variables,
1 2 3 4 5 6 7
|
const string Ham = " 1) Ham - $4.00\n";
const string Veggie = " 2) Veggie - $3.00\n";
const string Rat = " 3) Rat - $2.00\n";
const string Bacon = " Bacon - $0.50\n";
const string Hair = " Hair - $0.10\n";
const std::string Quit{ " 4) Quit\n\n" };
const std::string PROMPT{ "What type of sandwich do you want? " };
|
, The compiler would have given you an error when you tried to change a constant variable that can not be changed. That is usually a good indication that you need a different variable for input.
If you ignore the advice given or do not ask questions about what you do not understand we can not read your mind to know what you do not understand.
With all the code you have been shown and
seeplus's code that has most of your program written far enough that you could finish what he started. Something seems to be amiss.
When you get your program set up right it is very easy to add a "do/while" or "while" loop to allow for ordering more sandwiches.
You could add a menu choice for say "Total" to print a receipt of that order then "Quit" to leave the program. This may not be something that you need now, but may be the subject of the next assignment. If you try to prepare for it now it will be much easier later to modify the program.
Andy