Conversational issues

I wrote this, and I'm trying to figure out how to put the main bit of the conversation into a subroutine that I can call on throughout the program. Any suggestions?


#include <iostream>
#include <string>
using namespace std;


int main(void)
{
int choice1, choice2, choice3, choice4, choice5;
cout << "Hello.\n (How do you respond?)\n 1: Hello\n 2: What do you want?\n 3: (Walk Away)\n" << endl;
cin >> choice1;
if (choice1 == 1)
{
cout << "What's up?\n (How do you respond?) 1: Nothing\n 2: I need advice\n 3: I need money" << endl;
cin >> choice2;
if (choice2 == 1)
{
cout << "Okay. See ya later then." << endl;
return 0;
}
if (choice2 == 2)
{
cout << "What kind of advice?\n (How do you respond?)\n 1: Life\n 2: Love\n 3: Financial\n" << endl;
cin >> choice3;
if (choice3 == 1)
{
cout << "Never buy discount fish off a truck with Illinois license plates." << endl;
return 0;
}
if (choice3 == 2)
{
cout << "..." << endl;
return 0;
}
if (choice3 ==3)
{
cout << "Don't buy volcano insurance" << endl;
return 0;
}
}
if (choice2 == 3)
{
cout << "See ya later then." << endl;
return 0;
}
}
if (choice1 == 2)
{
cout << "No need to be rude, pal!\n(How do you respond?)\n 1: Sorry\n 2: You started this conversation!\n 3: (Shake your head and walk away)\n" << endl;
cin >> choice4;
if (choice4 == 1)
{
cout << "It's cool. So, what's going on?\n (How do you respond?)\n 1: Nothing\n 2: I need advice\n 3: I need money\n" << endl;
cin >> choice5;
}
if (choice5 == 1)
{
cout << "See ya later then." << endl;
}
if (choice5 == 2)
{
cout << "What kind?\n (How do you respond?)\n 1: Life\n 2: Love\n 3: Financial\n" << endl;
cin >> choice5;
if (choice5 == 1)
{
cout << "Never buy discount fish off a truck with an Illinois licens plate." << endl;
return 0;
}
if (choice5 == 2)
{
cout << "..." << endl;
return 0;
}
if (choice5 == 3)
{
cout << "Don't buy volcano insurance." << endl;
return 0;
}
}
if (choice4 == 2)
{
cout << "And I'm ending it!" << endl;
return 0;
}
if (choice4 == 3)
{
cout << "(You walk away)" << endl;
return 0;
}
}
if (choice1 == 3)
{
cout << "(You leave)" << endl;
return 0;
}
}
this would look much cleaner with functions and bool.
Topic archived. No new replies allowed.