Caeg

Untitled

Mar 8th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <fstream>
  6.  
  7.  
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. string sChoice, sTemp;
  14. vector <string> vData;
  15. ifstream inputfile;
  16. ofstream outputfile;
  17. const char READING = 'A', ADDING = 'B', DISPLAYING = 'C', SORTING = 'D', SAVING = 'E', SEARCHING = 'F', EXITING = 'G';
  18.  
  19. "\n Student Enrollment Application";
  20. "\n A. Reading an external student list"
  21. "\n B. Adding student's information into student list";
  22. "\n C. Displaying student list";
  23. "\n D. Sorting student list";
  24. "\n E. Saving student list to a file";
  25. "\n F. Searching from student list";
  26. "\n G. Exit the application";
  27.  
  28. do
  29. {
  30. cout << "\nWhat would you like to preform?";
  31. getline(cin, sChoice);
  32.  
  33. switch (toupper(sChoice[0]))
  34.  
  35. {
  36. case READING:
  37. cout << "Please enter the password";
  38. getline(cin, sTemp);
  39. inputfile.open(sTemp.c_str());
  40.  
  41. while (!inputfile)
  42. {
  43. cout << "\nWrong password, please re-enter";
  44. getline(cin, sTemp);
  45. inputfile.open(sTemp.c_str());
  46. }
  47. cout << "\nOpen succesfully! \n";
  48.  
  49. while (inputfile >> sTemp)
  50. {
  51. if (sTemp == "|");
  52. {
  53. sTemp = " ";
  54. sInfo += "\t\t";
  55. }
  56. else
  57. {
  58. sInfo += sTemp;
  59. }
  60. vData.push_text(sTemp);
  61. }
  62.  
  63. cout << "\nReading is succesful! \n";
  64. cout << "\nThe size of the list is " << vData.size() << endl;
  65.  
  66. inputfile.close();
  67. break;
  68.  
  69. case ADDING:
  70.  
  71. break;
  72.  
  73. case DISPLAYING:
  74.  
  75. if (vData.size() == 0);
  76. cout << "\nThe list is empty!\n";
  77.  
  78. for (int i = 0; i < vData.size(); i++)
  79. cout << vData[i] << endl;
  80.  
  81. break;
  82.  
  83.  
  84. case SORTING:
  85. if (vData.size() == 0)
  86. cout << "\nThe list is empty! \n";
  87.  
  88. sort(vData.begin(), vData.end());
  89. cout << "\nSorting is succesfull! \n";
  90. break;
  91.  
  92. case SAVING:
  93. cout << "\nPlease enter a file name";
  94. getline(cin, sTemp);
  95. outputfile.open(sTemp.c_str());
  96.  
  97. for (int i = 0; i < vData.size(), i++)
  98. outputfile << vData[i] << endl;
  99. outputfile.close();
  100.  
  101. break;
  102.  
  103. case SEARCHING:
  104.  
  105. break;
  106.  
  107. case EXITING:
  108.  
  109. break;
  110.  
  111. default:
  112. cout << "\nInvalid input!";
  113. break;
  114. }
  115. } while (sChoice[0], i = EXITING);
  116.  
  117. return 0;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment