Caeg

Untitled

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