another do while question
i am working on this program for my class, and i almost have this figured out. the problem is that since chocolate can be referred to as 2 different answers, that is where my program is going wacky. once i type in chocolate the first time, the first question is supposed to go away and ask me the second one. once i answer that, the second question is supposed to go away and ask me the final question. the program is working for every thing else (strawberry, hot fudge) except chocolate. i can type in chocolate the first time, the 1st question goes away, but once i type it in again, the second and third question are asked again and again and again (until the counter reaches 100).
if you need me to explain this better let me know.
here is the assignment description:
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. Use the screen shots
below as a guide. 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.
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string icecream = "", answer, sauce = "", sprinkles = "";
int kwb = 0;
do
{
if (kwb++ > 100)
break;
if (icecream == "")
cout << "Do you want chocolate, vanilla or twist? " << endl;
if (sauce == "")
cout << "Hot fudge, chocolate or strawberry sauce? " << endl;
if (sprinkles == "")
cout << "Do you want sprinkles (yes/no)? " << endl;
getline (cin, answer);
if ((answer == "chocolate")&&(sauce == ""))
{
icecream = "chocolate";
}
else
{
if ((answer == "vanilla")||(answer == "twist"))
icecream = answer;
if ((answer == "hot fudge")||(answer == "strawberry"))
sauce = answer;
if ((answer == "yes")||(answer == "no"))
sprinkles = answer;
}
} while ((icecream == "")||(sauce == "")||(sprinkles == ""));
if (sprinkles == "yes")
cout << "You ordered " << icecream << " ice cream with " << sauce << " sauce and sprinkles." << endl;
if (sprinkles == "no")
cout << "You ordered " << icecream << " ice cream with " << sauce << " sauce without sprinkles." << endl;
}
thanks for the help guys.