Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iomanip>
- #include <cstdlib>
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <cstdlib>
- #include <ctime>
- #include <cctype>
- #include <fstream>
- using namespace std;
- void displaydata(int);
- int main()
- {
- string sChoice, sTemp, sInfo, sArray;
- vector <string> vData;
- ifstream inputfile;
- ofstream outputfile;
- int iCounter;
- const char READING = 'A', ADDING = 'B', DISPLAYING = 'C', SORTING = 'D', SAVING = 'E', SEARCHING = 'F', EXITING = 'G';
- cout << "\n Student Enrollment Application";
- cout << "\n A. Reading an external student list";
- cout << "\n B. Adding student's information into student list";
- cout << "\n C. Displaying student list";
- cout << "\n D. Sorting student list";
- cout << "\n E. Saving student list to a file";
- cout << "\n F. Searching from student list";
- cout << "\n G. Exit the application";
- {
- cout << "\nWhich option would you like to preform? Select an option from A through G. ";
- getline(cin, sChoice);
- switch (toupper(sChoice[0]))
- {
- case READING:
- // This case allows for you to upload a file. You must enter the file's name as the password to open it.
- cout << "Please enter the password: ";
- getline(cin, sTemp);
- inputfile.open(sTemp.c_str());
- // This gives you an error if the password is incorrect.
- if (!inputfile)
- {
- cout << "\nWrong password, please re-enter: ";
- getline(cin, sTemp);
- inputfile.open(sTemp.c_str());
- }
- cout << "\nOpen succesfully! \n";
- // This tells you if you've typed in the correct password.
- if (inputfile)
- {
- cout << "\nThat's the correct password!";
- }
- cout << "\nReading is succesful!\n";
- cout << "\nThe size of the list is: " << vData.size() << endl;
- while (getline(inputfile, sTemp))
- iCounter++;
- string sArray[iCounter];
- while (inputfile >> sTemp)
- {
- if (sTemp == "|");
- {
- sTemp = " ";
- sInfo += (sTemp + "\t\t");
- }
- if (sTemp != "|");
- {
- sInfo += sTemp;
- }
- vData.push_text(sTemp);
- inputfile.close();
- break;
- case ADDING:
- cout << "\nThe student list's size right now is: ";
- 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:
- case EXITING:
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment