I am having trouble with this program which was solved before, but I am still having an issue with the final code. Here is the assignment prompt:
Write a program that asks the user to order an ice cream treat. The user selects the type of ice cream, the type of sauce, and whether or not to add sprinkles. NOTE: "chocolate" may refer to either the ice cream or the sauce; assume it refers to the ice cream if an ice cream flavor has not yet been selected.
I have also attached pictures of what it should look like.
My problem is that when I run the program, and then I say "yes" or "no", trying to answer the sprinkles question, it ignores my response and still repeats all three questions, despite me having answered the sprinkles question. How can I alleviate this? I could really use the help...Thank you very much in advance for anyone that helps me.
Here is my code so far:
int main()
{
string flavor, topping, sprinkles, choice;
int terminate = 0;
while( sprinkles == "")
{
if (terminate++ > 30)
{
break;
}
if( flavor == "")
{
cout << "Do you want chocolate, vanilla or twist?" << endl;
}
if( topping == "")
{
cout << "Hot fudge, chocolate or strawberry sauce?" << endl;
}
if( sprinkles == "")
{
cout << "Do you want sprinkles (yes/no)?" << endl;
}
getline(cin, choice);
if( sprinkles == "" && topping != "" && flavor != "")
{
if( choice == "yes" || choice =="no" )
{
sprinkles = choice;
}
}
if( sprinkles == "" && topping == "" && flavor != "")
{
if( choice == "hot fudge" || choice == "chocolate" || choice == "strawberry" )
{
topping = choice;
}
}
if( sprinkles == "" && topping == "" && flavor == "")
{
if( choice == "chocolate" || choice == "vanilla" || choice == "twist" )
{
flavor = choice;
}
}
}
if (sprinkles == "yes")
{
cout << "You ordered " << flavor << " ice cream with " << topping << " sauce and sprinkles." << endl;
}
else
{
cout << "You ordered " << flavor << " ice cream with " << topping << " sauce without sprinkles." << endl;
}
}