Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <fstream>
- using namespace std;
- int main()
- {
- string sChoice, sTemp;
- vector <string> vData;
- ifstream inputfile;
- ofstream outputfile;
- const char READING = 'A', ADDING = 'B', DISPLAYING = 'C', SORTING = 'D', SAVING = 'E', SEARCHING = 'F', EXITING = 'G';
- "\n Student Enrollment Application";
- "\n A. Reading an external student list"
- "\n B. Adding student's information into student list";
- "\n C. Displaying student list";
- "\n D. Sorting student list";
- "\n E. Saving student list to a file";
- "\n F. Searching from student list";
- "\n G. Exit the application";
- do
- {
- cout << "\nWhat would you like to preform?";
- getline(cin, sChoice);
- switch (toupper(sChoice[0]))
- {
- case READING:
- cout << "Please enter the password";
- getline(cin, sTemp);
- inputfile.open(sTemp.c_str());
- while (!inputfile)
- {
- cout << "\nWrong password, please re-enter";
- getline(cin, sTemp);
- inputfile.open(sTemp.c_str());
- }
- cout << "\nOpen succesfully! \n";
- while (inputfile >> sTemp)
- {
- if (sTemp == "|");
- {
- sTemp = " ";
- sInfo += "\t\t";
- }
- else
- {
- sInfo += sTemp;
- }
- vData.push_text(sTemp);
- }
- cout << "\nReading is succesful! \n";
- cout << "\nThe size of the list is " << vData.size() << endl;
- inputfile.close();
- break;
- case ADDING:
- break;
- case DISPLAYING:
- if (vData.size() == 0);
- cout << "\nThe list is empty!\n";
- for (int i = 0; i < vData.size(); i++)
- cout << vData[i] << endl;
- break;
- case SORTING:
- if (vData.size() == 0)
- cout << "\nThe list is empty! \n";
- sort(vData.begin(), vData.end());
- cout << "\nSorting is succesfull! \n";
- break;
- case SAVING:
- cout << "\nPlease enter a file name";
- getline(cin, sTemp);
- outputfile.open(sTemp.c_str());
- for (int i = 0; i < vData.size(), i++)
- outputfile << vData[i] << endl;
- outputfile.close();
- break;
- case SEARCHING:
- break;
- case EXITING:
- break;
- default:
- cout << "\nInvalid input!";
- break;
- }
- } while (sChoice[0], i = EXITING);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment