Caeg

Untitled

Feb 18th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. vector <string> vName, vID, vClass;
  11. string sName, sID, sClass;
  12. string sTemp;
  13. int iStudent;
  14.  
  15. // Displays text stating the starting size of the student list
  16. cout << "\nThe student list starts with the size of: " << vName.size() << endl;
  17.  
  18. // Displays text to the user requesting to input an amount of students to add to the list
  19. cout << "\nHow many students would you like to add: ";
  20.  
  21. // Gathers the amount of students requesting to be added
  22. cin >> iStudent;
  23.  
  24. //
  25. cin.ignore();
  26.  
  27. //
  28. for (int i = 0; i < iStudent; i++)
  29.  
  30. {
  31. // Displays the student number
  32. cout << "\nStudent " << i + 1 << ":";
  33.  
  34. // Displays text requesting for the student's name
  35. cout << "\nPlease enter the student's name:\t";
  36.  
  37. // Gathers the name submited
  38. getline(cin, sName);
  39.  
  40. //
  41. vName.push_back(sName);
  42.  
  43. // Displays text requsting the student's ID
  44. cout << "\nPlease enter the student's ID:\t\t";
  45.  
  46. // Gathers the ID submited
  47. getline(cin, sID);
  48.  
  49. //
  50. vID.push_back(sID);
  51.  
  52. // Displays text requesting the student's class
  53. cout << "\nPlease enter the student's class:\t";
  54.  
  55. // Gathers the class submited
  56. getline(cin, sClass);
  57.  
  58. //
  59. vClass.push_back(sClass);
  60.  
  61. }
  62. // Displays a line of text stating the size of the class, and the information for each student
  63. cout << "\nThe student list has a size of: " << vName.size() << "\n";
  64. cout << "\nThe student list is: ";
  65. cout << "\nName: \t\t ID: \t\t Enrolled classes";
  66. cout << "\n--------------------------------------------------------------------------------\n";
  67.  
  68.  
  69. for (int i = 0; i < vName.size(); i++)
  70. {
  71. cout << endl << vName[i] << "\t\t" << vID[i] << "\t\t" << vClass[i] << "\n\n";
  72.  
  73.  
  74. cout << " \nThe student list after sorting: \n\n";
  75.  
  76. do
  77. {
  78. if (binary_search(vName.begin(), vName.end(), sTemp))
  79. cout << "The name was found!";
  80.  
  81. else
  82. cout << "The name was not found.";
  83. }
  84. }
  85.  
  86.  
  87. {
  88. cout << "\nWould you like to do this again: Y for Yes, N for No?\n";
  89. getline(cin, sTemp);
  90.  
  91. } while(sTemp[0] == 'Y' || sTemp[0] == 'y');
  92.  
  93. if (sTemp[0] == 'N' || sTemp[0] == 'n')
  94. cout << "\nThanks for using this program!\n";
  95.  
  96. return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment