There are two separate problems here. First, the || operators here:
|
while (option != "First choice" || option != "Second choice" || option != "Third Choice")
| |
should actually be &&, like this:
|
while (option != "First choice" && option != "Second choice" && option != "Third Choice")
| |
The second problem, is that you ask the user to enter not just a single letter or number, but a whole phrase, such as
"Second choice"
, however when you do this:
1 2
|
string option;
cin >> option;
| |
the user types in "Second choice" but the variable
option
will contain just the first word, "Second"
If you want to get the whole of the input as a string, you need to use getline, like this:
However, it's tedious for the user to have to enter such a lot of text, where they might mistype something, for example by adding an extra space or something seemingly insignificant. Usually its better to keep the user input short and to the point, such as a single character.
char option;