#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string ans, name;
cout << "Hello what is your name" << endl;
cin >> name;
cout << "Nice to meet your " << name << endl;
while (true) //infinite loop
{
cout << "How is your day " << name << endl;
cin >> ans;
// if (ans.eguals("good"))
if (ans == "good")
{
cout << "Thats good, enjoy the rest of your day" << endl;
break; //here it will exit the loop the same for all the else if
}
// if (ans.equals("fine"))
elseif (ans == "fine")
{
cout << "Just fine not good" << endl;
break; //here it will exit the loop the same for all the else if
}
// if (ans.equals("bad"))
elseif (ans == "bad")
{
cout << "Thats too bad, i hope you have a better day tomarrow" << endl;
break; //here it will exit the loop the same for all the else if
}
//if (ans.equals("great"))
elseif (ans == "great")
{
cout << "thats awesome to hear" << endl;
break; //here it will exit the loop the same for all the else if
}
//if (ans.equals("terible"))
elseif (ans == "terible")
{
cout << "thats terible to here, im sorry" << endl;
break; //here it will exit the loop the same for all the else if
}
else
{
cout << "sorry thats none of the choices try good, fine, bad, great, or terible, thank you" << endl;
continue; //will reloop (test the condition and since it's true reloop)
}
}
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string ans, name;
cout << "Hello what is your name" << endl;
cin >> name;
cout << "Nice to meet your " << name << endl;
while (true) //infinite loop
{
cout << "How is your day " << name << endl;
cin >> ans;
// if (ans.eguals("good"))
if (ans == "good")
{
cout << "Thats good, enjoy the rest of your day" << endl;
break; //here it will exit the loop the same for all the else if
}
// if (ans.equals("fine"))
elseif (ans == "fine")
{
cout << "Just fine not good" << endl;
break; //here it will exit the loop the same for all the else if
}
// if (ans.equals("bad"))
elseif (ans == "bad")
{
cout << "Thats too bad, i hope you have a better day tomarrow" << endl;
break; //here it will exit the loop the same for all the else if
}
//if (ans.equals("great"))
elseif (ans == "great")
{
cout << "thats awesome to hear" << endl;
break; //here it will exit the loop the same for all the else if
}
//if (ans.equals("terible"))
elseif (ans == "terible")
{
cout << "thats terible to here, im sorry" << endl;
break; //here it will exit the loop the same for all the else if
}
else
{
cout << "sorry thats none of the choices try good, fine, bad, great, or terible, thank you" << endl;
continue; //will reloop (test the condition and since it's true reloop)
}
}
return 0;
}