Hey. Thanks for all of the help with my other questions. This forum has been very helpful. In this program, there is a 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. So, if I enter chocolate for the first question, it automatically skips the second (which asks for type of sauce) and goes right to the last question. How can I arrange it so that I can get input data to get an output such as: You have selected chocolate ice cream with hot fudge sauce and sprinkles?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string softserve = "", topping = "", sprinkles = "";
string order;
do
{
if (softserve == "")
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, order);
if ((order == "chocolate") || (order == "vanilla")
|| (order == "twist"))
softserve = order;
if ((order == "hot fudge") || (order == "chocolate")
|| (order == "strawberry"))
topping = order;
if ((order == "yes") || (order == "no"))
sprinkles = order;
} while ((softserve == "") || (topping == "") || (sprinkles == ""));
if (sprinkles == "yes")
cout << "You ordered " << softserve << " ice cream with " << topping
<< " sauce and sprinkles." << endl;
else if (sprinkles == "no")
cout << "You ordered " << softserve << " ice cream with " << topping
<< " sauce without sprinkles." << endl;
}