In: Computer Science
modify this program to either simulate a teacher or used car salesperson.
#include <iostream>
#include <string>
using namespace std;
int Menu(string a, string b, string c)
{ int choice =-1;
cout<<" 1)"<<a<<endl;
cout<<" 2)"<<b<<endl;
cout<<" 3)"<<c<<endl;
cout<<" 4) I don't want to talk to you!!"<<endl;
cin>>choice;
return choice;
}
int Money(int x)
{ int c=-1;
cout<<"\n Are you that materialistic? \n";
c = Menu(" No.", " Yes.", " Can we talk about something
else?");
if(c == 1|| c ==2 )
c=-1;
else if (c == 3 )
c =3;
return c;
}
int Relationship(int x)
{ int c=-1;
cout<<"\n What is your relationship like with this
person?\n";
c = Menu(" Like, my best friend.", " We are not really that
close.", " Can we talk about something else?");
if(c == 1|| c ==2 )
c=-1;
else if (c == 3 )
c =3;
return c;
}
int Work(int x)
{ int choice=-1;
cout<<"\n What is going on at your job? \n";
choice = Menu(" The boss is a great!", " I just got a raise.", "
There is this really cute collegue.");
if(choice == 1|| choice ==3 )
choice = Relationship(choice);
else if (choice == 2 )
choice = Money(choice);
return choice;
}
int main()
{ int answer=-1;
cout<<"\n Hi! How are you feeling today? \n";
answer = Menu(" Excellent!", " OK.", " Bad.");
do {
if(answer == 1 )
{ cout<<"\n What makes things so good? \n";
answer = Menu(" Your Job?", " Your friend", " Your sister or
Brother?");
if(answer == 1 )
answer = Work(answer);
else if (answer == 2 || answer ==3 )
answer = Relationship(answer);
}
else if (answer == 2)
{ cout<<"\n Did something happen? \n";
answer = Menu(" No.", " Yes.", " Can we talk about something
else?");
if(answer == 1)
{ cout<<" \n\n I think we need to talk about it.
\n\n\n";
answer = -1;
}
else if (answer == 2)
{ cout<<"\n Did I do something to upset you?\n";
answer =Menu(" No.", " Yes.", " Let's talk about something
else?");
if(answer == 1)
answer =2;
else if (answer == 2)
answer =3;
else if (answer==3)
answer =-1;
}
else if (answer==3)
answer =-1;
}
else if (answer == 3)
{ cout<<"\n I am sorry to hear that. Can you tell me more?
\n";
answer = Menu(" No.", " Yes.", " Let's talk about something
else?");
if(answer == 1)
{ cout<<" \n\n I think we need to talk about it.
\n\n\n";
answer = -1;
}
else if (answer == 2)
answer =2;
else if (answer==3)
answer =-1;
}
else if (answer == 4)
cout<<"OK. Have a nice day.\n\n\n";
else
{ cout<<"\n How do you feel about
that?"<<endl<<endl;
answer = Menu( " Very happy."," Terrible.", " Let's talk about
something else?");
}
} while (answer != 4);
cout<<" Bye!\n\n\n\n";
system("PAUSE");
return 0;
}