Caeg

Project 3

Mar 3rd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 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. case READING:
  36. cout << "Please enter the password";
  37. getline(cin, sTemp);
  38. inputfile.open(sTemp.c_str());
  39.  
  40. while (!inputfile)
  41. {
  42. cout << "\nWrong password, please re-enter";
  43. getline(cin, sTemp);
  44. inputfile.open(sTemp.c_str());
  45. }
  46. cout << "\nOpen succesfully! \n";
  47.  
  48. while (inputfile >> sTemp)
  49. cout << sTemp << endl;
  50.  
  51.  
  52. cout << "\nReading is succesful! \n";
  53. cout << "\nThe size of the list is " << vData.size() << endl;
  54.  
  55. inputfile.close();
  56. break;
  57.  
  58. case ADDING:
  59.  
  60. break;
  61.  
  62. case DISPLAYING:
  63.  
  64. if (vData.size() = 0);
  65. cout << "\nThe list is empty!\n";
  66.  
  67. for (int i = 0; i < vData.size(); i++)
  68. cout << vData[i] << endl;
  69.  
  70. break;
  71.  
  72. case SORTING:
  73.  
  74. break;
  75.  
  76. case SAVING:
  77.  
  78. break;
  79.  
  80. case SEARCHING:
  81.  
  82. break;
  83.  
  84. case EXITING:
  85.  
  86. break;
  87.  
  88. default:
  89. cout << "\nInvalid input!";
  90. break;
  91. }
  92. }
  93. while (sChoice[0], i = EXITING);
  94.  
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment