riggnaros

Mindtap10_11_main

Apr 6th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. //main
  2.  
  3. #include <iostream>
  4. #include <iomanip>
  5. #include "mindtap_10_11_header.h"
  6.  
  7. using namespace std;
  8.  
  9. void menu(personType newPerson)
  10. {
  11.     int selection = 0;
  12.     char answer;
  13.     string first, middle, last;
  14.  
  15.     cout << "Would you like to use the Program?(Y/N) \n";
  16.     cin >> answer;
  17.  
  18.     while (answer == 'y' || answer == 'Y') {
  19.  
  20.  
  21.         cout << "Please enter your selection: \n";
  22.         cout << "1. Print Name.\n";
  23.         cout << "2. Set Full Name.\n";
  24.         cout << "3. Set First Name.\n";
  25.         cout << "4. Set Middle Name.\n";
  26.         cout << "5. Set Last Name.\n";
  27.         cout << "6. Exit.\n";
  28.         cin >> selection;
  29.  
  30.  
  31.         if (selection == 1)
  32.             newPerson.printName();
  33.         else if (selection == 2)
  34.             newPerson.setName(first, middle, last);
  35.         else if (selection == 3)
  36.             newPerson.setFName(first);
  37.         else if (selection == 4)
  38.             newPerson.setMName(middle);
  39.         else if (selection == 5)
  40.             newPerson.setLName(last);
  41.         else if (selection == 6)
  42.             exit(0);
  43.         else
  44.             cout << "Please enter a valid selection (1-6)\n";
  45.     }
  46. };
  47.  
  48.  
  49. int main()
  50. {
  51.     personType newPerson;
  52.  
  53.     menu(newPerson);
  54.  
  55.     return 0;
  56. };
Add Comment
Please, Sign In to add comment