Caeg

Untitled

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