Caeg

Untitled

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