Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <string>
- #include <iostream>
- #include <fstream>
- using namespace std;
- /*
- To do list:
- Student Scores
- -Find a way to loop through student ID's. (90% done)
- Why does it get the second line 2x?
- -Write input scores to file
- -If menu option is chosen once, can't return to it. Why?
- Grading
- -Create Grading Function
- */
- int main(int argc, char* argv[]) {
- int mainMenuChoice;
- int gradeMenuChoice;
- int quizzes[14];
- int homework[10];
- int labs[7];
- int tests[3];
- int project;
- int discussion;
- int teamwork;
- int extraCredit;
- int i = 0;
- int j = 0;
- int delimiter = 0;
- int studentID;
- string fname;
- string lname;
- string phoneNumber;
- string line;
- string studentId;
- string str;
- string filename = "studentGrade.txt";
- char charChoice;
- char studentChar;
- bool showGradeMenu = true;
- bool showMainMenu = true;
- bool addStudent = true;
- bool readLine = true;
- ifstream inputfile;
- ofstream outputfile;
- while (showMainMenu != false) {
- system("cls");
- cout << "----------------------------------------" << endl;
- cout << "\t STUDENT GRADEBOOK \t" << endl;
- cout << " 1 - Enter Student Information" << endl;
- cout << " 2 - Enter Student Scores" << endl;
- cout << " 3 - Grading" << endl;
- cout << " 0 - Exit" << endl;
- cout << "----------------------------------------" << endl;
- cout << "Please select an option from the menu: ";
- cin >> mainMenuChoice;
- cout << endl;
- switch (mainMenuChoice)
- {
- //Student Information
- case 1: {
- system("cls");
- cout << "Student Information:" << endl;
- outputfile.open(filename, fstream::app);
- while (addStudent != false) {
- cout << "Would you like to add a student? (Y/N) ";
- cin >> studentChar;
- switch (studentChar)
- {
- case 'Y':
- case 'y': {
- system("cls");
- cout << "Enter Student Name: ";
- cin >> fname >> lname;
- cout << "Enter Student ID: ";
- cin >> studentID;
- cout << "Enter Student Phone Number: ";
- cin >> phoneNumber;
- cout << endl;
- outputfile << studentID << "," << lname << "," << fname << "," << phoneNumber << endl;
- break; }
- case 'N':
- case 'n': {
- addStudent = false;
- cout << "Student Entry Complete. " << endl;
- system("pause");
- break; }
- default: {
- cout << "Invalid Selection. Please select an option from the menu:";
- cin >> studentChar;
- break; }
- }
- }
- outputfile.close();
- break;
- }
- //Student Scores
- case 2: {
- system("cls");
- cout << "Student Scores:" << endl;
- inputfile.open(filename);
- if (inputfile.is_open()) {
- while (inputfile.good()) {
- inputfile >> line;
- delimiter = line.find_first_of(',');
- studentId = line.substr(0, delimiter);
- str = line.substr(delimiter + 1);
- outLoop:
- cout << "Would you like to enter grades for student ID: " << studentId << "? (Y/N)";
- cin >> charChoice;
- while (readLine != false) {
- switch (charChoice)
- {
- case 'Y':
- case 'y': {
- system("cls");
- while (showGradeMenu != false) {
- system("cls");
- cout << "----------------------------------------" << endl;
- cout << "\t Assignments \t" << endl;
- cout << " 1 - Quizzes" << endl;
- cout << " 2 - Homework" << endl;
- cout << " 3 - Labs" << endl;
- cout << " 4 - Tests" << endl;
- cout << " 5 - Project" << endl;
- cout << " 6 - Discussion" << endl;
- cout << " 7 - Team Work" << endl;
- cout << " 8 - Extra Credit" << endl;
- cout << " 0 - Exit" << endl;
- cout << "----------------------------------------" << endl;
- cout << "Please select an option from the menu: ";
- cin >> gradeMenuChoice;
- cout << endl;
- switch (gradeMenuChoice)
- {
- case 1: {
- system("cls");
- cout << "Enter the quiz scores: " << endl;
- i = 0;
- do {
- cin >> quizzes[i];
- i++;
- } while (i < 13);
- for (j = 0; j < 13; j++) {
- cout << quizzes[j] << " ";
- }
- cout << endl;
- system("pause");
- break; }
- case 2: {
- system("cls");
- cout << "Enter the homework scores: " << endl;
- i = 0;
- do {
- cin >> homework[i];
- } while (homework[i] < 9);
- for (j = 0; j < 9; j++) {
- cout << homework[j] << " ";
- }
- cout << endl;
- system("pause");
- break; }
- case 3: {
- system("cls");
- cout << "Enter the lab scores: " << endl;
- i = 0;
- do {
- cin >> labs[i];
- } while (labs[i] < 9);
- for (j = 0; j < 9; j++) {
- cout << labs[j] << " ";
- }
- system("pause");
- break; }
- case 4: {
- system("cls");
- cout << "Enter the test scores: " << endl;
- i = 0;
- do {
- cin >> tests[i];
- } while (tests[i] < 2);
- for (j = 0; j < 2; j++) {
- cout << tests[j] << " ";
- }
- cout << endl;
- system("pause");
- break; }
- case 5: {
- system("cls");
- cout << "Enter the project score: " << endl;
- cin >> project;
- cout << project << endl;
- system("pause");
- break; }
- case 6: {
- system("cls");
- cout << "Enter the discussion score: " << endl;
- cin >> discussion;
- cout << discussion << endl;
- system("pause");
- break; }
- case 7: {
- system("cls");
- cout << "Enter the team work score: " << endl;
- cin >> teamwork;
- cout << teamwork << endl;
- system("pause");
- break; }
- case 8: {
- system("cls");
- cout << "Enter the extra credit score:" << endl;
- cin >> extraCredit;
- cout << extraCredit << endl;
- system("pause");
- break; }
- case 0: {
- system("cls");
- cout << "Exiting...\n" << endl;
- showGradeMenu = false;
- system("pause");
- goto outLoop; }
- default: {
- cout << "Invalid Selection. Please select an option from the menu:";
- cin >> gradeMenuChoice;
- break;
- }
- }
- }
- break;
- }
- case 'N':
- case 'n': {
- system("cls");
- readLine = false;
- break;
- }
- default: {
- cout << "Invalid Selection. Please select an option from the menu:";
- cin >> charChoice;
- break;
- }
- }
- }
- }
- }
- outputfile.close();
- break;
- }
- //Grading
- case 3: {
- system("cls");
- cout << "Grading" << endl;
- //Input Grading function here
- break;
- }
- //Exit
- case 0: {
- system("cls");
- cout << "End of Program.\n" << endl;
- showMainMenu = false;
- break;
- }
- default: {
- cout << "Invalid Selection. Please select an option from the menu:";
- cin >> mainMenuChoice;
- break;
- }
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement