I am having a problem calling a function from another function. What I want to occur is after the user enters their firstName and lastName. I want use the fullName thought the program
Thank you,
string Getname()
{
string firstName, lastName, fullName;
cout << "\tPlease enter your first name: ";
cin >> firstName;
//getline(cin, firstName);
cout << endl;
cout << "\tPlease enter your last name: ";
cin >> lastName;
//getline(cin, lastName);
firstName[0] = toupper (firstName[0]);
lastName[0] = toupper (lastName[0]);
fullName = firstName + " " + lastName;
cout << endl;
return fullName;
}
void showMainMenu()
{
int choice;
string fullName;
fullName = Getname();
cout << endl << endl;
cout << "\tWelcome " << fullName << " to CS-162 Main menu.\n";
cout << "\tPlease Enter a menu number: 1, 2, 3, 4, or 5 to exit.\n";
cout << endl;
cout << "\t1) Movie menu 2) report\n";
cout << "\t3) alibi 4) comfort\n";
cout << "\t5) quit\n";
cout << endl << endl;
cout << "\t...: ";
cin >> choice;
while (choice != 5)
{
switch (choice)
{
case 1 : showMovieMenu();
break;
case 2 : report();
break;
case 3 : cout << "\tThe boss was in all day.";
break;
case 4 : comfort();
break;
default : cout << "\tThat's not a good choice.\n";
}
showMainMenu();
cout << "\t...: ";
cin >> choice;
}
if (choice == 5)
{
cout << endl << endl;
cout << "\tThank you.\n\n\n";
exit(1);
}
}
void showMovieMenu()
{
int ans;
cout << endl << endl;
cout << "\tWelcome to CS-162 Movie menu.\n";
cout << "\tPlease Enter a Movie menu item: 1, 2, 3, 4, or 5 to exit.\n";
cout << endl;
cout << "\t1) Add Movie 2) report\n";
cout << "\t3) alibi 4) comfort\n";
cout << "\t5) quit\n";
cout << endl << endl;
cout << "\t...: ";
cin >> ans;
while (ans != 5)
{
switch(ans)
{
case 1 : addMovie();
break;
case 2 : report();
break;
case 3 : cout << "\tThe boss was in all day.\n";
break;
case 4 : comfort();
break;
default : cout << "\tThat's not a choice.\n";
}
showMovieMenu();
cout << "\t...: ";
cin >> ans;
}
cout << endl << endl;
cout << "\tThank you for using CS-162 Movie menu!\n\n\n";
if (ans == 5)
{
showMainMenu();
}
}

New Topic/Question
Reply




MultiQuote





|