Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <cstring>
- #include <string>
- #include <iomanip>
- #include <cstdlib>
- #include <vector>
- //#include "student.h"
- #include "studentList.h"
- using namespace std;
- const int fileNameSize = 20;
- ofstream outFile;
- //char inputFileName [fileNameSize+1];
- //char outputFilename [fileNameSize+1];
- studentList stList;
- string id, name;
- void showmenu()
- {
- cout << "Please type in one of the following opotions: \n";
- cout << "L or l to load the student list \n";
- cout << "D or d to display the student data \n";
- cout << "P or p to process grades\n";
- cout << "C or c to change a student \n";
- cout << "A or a to add a student. \n";
- cout << "S or s to search for a particular student's information \n";
- cout << "R or r to print the total grades and letter grade \n";
- cout << "M or m to display this menu \n";
- cout << "E or e to save and exit \n";
- }
- void loadStudents()
- {
- string dummy;
- int hpScores[10];
- int tScores[4];
- ifstream inFile;
- student st;
- string filename;
- string name;
- filename = "studentprofs.txt";
- cout << "Loading students... \n";
- inFile.open(filename);
- cout << "open check" << endl;
- if (!inFile)
- {
- cout << "Error, could not load/find file.";
- inFile.close();
- inFile.clear();
- return;// choice;
- }
- cout << name << endl;
- st.setName(name);
- while (!inFile.eof())
- {
- cout << "open flag";
- inFile >> name;
- cout << " " << name;
- inFile >> id; st.setID(id);
- cout << " " << id;
- for (int i = 0; i<10; i++)
- {
- inFile >> hpScores[i];
- cout << " " << hpScores[i] << " ";//<< endl;
- }
- cout << endl;
- st.setHPScores(hpScores);
- for (int i = 0; i<4; i++)
- {
- inFile >> tScores[i];
- cout << " " << tScores[i] << " ";//<< endl;
- }
- cout << endl;
- st.setTestScores(tScores);
- stList.addStudent(st);
- // inFile >> name;
- st.setName(name);
- }
- }
- void displayStudentProfile()
- {
- cout << "Displaying data...\n";
- }
- void processGrades()
- {
- cout << "Processing grades... \n";
- }
- void changeGrades()
- {
- cout << "Changing student grade(s)...\n";
- }
- void addStudent()
- {
- cout << "Adding student... \n";
- }
- void searchStudent()
- {
- cout << "Searhing student...\n";
- }
- void saveInfo()
- {
- cout << "Saving data...";
- }
- void printGrades()
- {
- cout << "Printing total grades and letter grade...";
- }
- int main()
- {
- int ilchk = 0;
- char choice = 'm';
- string wastedata;
- showmenu();
- cout << "Please indicate your choice of operation (m for menu): ";
- cin >> choice;
- while ((choice != 'e') && (choice != 'E') && ilchk<5)
- {
- switch (choice)
- {
- case 'l':
- case 'L': loadStudents(); cin.ignore(400, '\n'); cin.clear(); break;
- case 'd':
- case 'D': displayStudentProfile(); cin.ignore(400, '\n'); cin.clear(); break;
- case 'p':
- case 'P': processGrades(); cin.ignore(400, '\n'); cin.clear(); break;
- case 'c':
- case 'C': changeGrades(); cin.ignore(400, '\n'); cin.clear(); break;
- case 'a':
- case 'A': addStudent(); cin.ignore(400, '\n'); cin.clear(); break;
- case 's':
- case 'S': searchStudent(); cin.ignore(400, '\n'); cin.clear(); break;
- case 'r':
- case 'R': printGrades(); cin.ignore(400, '\n'); cin.clear(); break;
- case 'm':
- case 'M': showmenu(); cin.ignore(400, '\n'); cin.clear(); break;
- case 'e':
- case 'E': cin.ignore(400, '\n'); cin.clear(); break;
- default: cout << "Invalid command." << endl;
- }
- cout << "Please indicate your choice of operation (m for menu): ";
- cin >> choice;
- ilchk++;
- }
- saveInfo();
- cout << "Thank you, have a good one!\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement