1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/* This is a program which poses questions to the user. If the user awnsers something, it'll ask the next question
based on the previous awnser...
The interface is meant to be as if it's some sort of chat
*/
#include <iostream>
#include <string>
#include <windows.h>
using std::cout;
using std::cin;
using std::getline;
using std::tolower;
using std::endl;
using std::string;
int main (int argc, char * argv[])
{
std::string name;
cout<<"Program says: Hi, what's your name?"<<endl; //q for name
cout<<"User says: ";
std::getline (cin,name); //get name
cout<<"Program says: Hi "<<name<<", are you fine?"<<endl; //how are you?
cout<<"User says: ";
string ans;
getline(cin,ans);
if((ans == "yes")||(ans =="Yes")) {cout<<"Program says: That's great! I'm fine to :)"<<endl;} //if yes say me 2
else{cout<<"Program says: Don't worry, it'll be allright!"<<endl;} //if no, encourage user
cout<<"Program says: So tell me, "<<name<< ",do you like today's weather too?"<<endl;
cout<<"User says: ";
getline(cin,ans);
if((ans == "yes")||(ans == "Yes"))
{cout<<"\nProgram says: Cool!";}
cout<<"So what kind of weather do you like?\nCloudy, Sunny, Rainy, Windy, Humid or Dry? ";
string weth;
getline (cin,weth);
if(weth == "cloudy"){cout<<"Prgoram says: I guess it's okay if it's cloudy sometimes"<<endl;}
else if(weth == "sunny"){cout<<"Program says: I love it when it's sunny!"<<endl;}
else if(weth == "windy")
{
cout<<"Program says: I only like that when it's hot.. You too?";
getline (cin,ans);
if((ans == "yes")||(ans=="Yes"))
{cout<<"Great! That's something we have in common then!"<<endl;}
else {cout<<"Ah well, people differ"<<endl;}
}
return 0;
}
|