I am trying to use if else statements to make sure a string has one of two sets of characters, "Yes" or "No". When I run the rest of the code I get to the integer input for the theme, but immediately after inputting the integer the code jumps to the invalid value if statement.
cout << "On a scale of 1-10, how much do you like movies with a similar theme? ";
cin >> theme;
cout << endl;
if (theme < 1 || theme > 10)
{
cout << "Invalid theme value!";
return (-1);
}
cout << "Do you like movies starring the actor or actress that stars in this movie? ";
getline(cin, actor);
cout << endl;
if ((actor != "Yes" && actor != "No"))
{
cout << "Invalid actor value!";
return(-1);
}
else if (actor == "Yes")
{
b = 2.0;
}
else
{
b = 0.0;
}
I've tried going back to just using cin >> but if you input a string such as Yes and no, it recognizes only the Yes and tries to ouput a valid statement.