Advertisement
Fabled_Knight

Untitled

Mar 19th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.17 KB | None | 0 0
  1. #include <iomanip>
  2. #include <string>
  3. #include <iostream>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. /*
  9. To do list:
  10.  
  11. Student Scores
  12. -Find a way to loop through student ID's. (90% done)
  13.     Why does it get the second line 2x?
  14. -Write input scores to file
  15.  
  16. -If menu option is chosen once, can't return to it. Why?
  17.  
  18. Grading
  19. -Create Grading Function
  20. */
  21.  
  22. int main(int argc, char* argv[]) {
  23.     int mainMenuChoice;
  24.     int gradeMenuChoice;
  25.     int quizzes[14];
  26.     int homework[10];
  27.     int labs[7];
  28.     int tests[3];
  29.     int project;
  30.     int discussion;
  31.     int teamwork;
  32.     int extraCredit;
  33.     int i = 0;
  34.     int j = 0;
  35.     int delimiter = 0;
  36.     int studentID;
  37.  
  38.     string fname;
  39.     string lname;
  40.     string phoneNumber;
  41.     string line;
  42.     string studentId;
  43.     string str;
  44.     string filename = "studentGrade.txt";
  45.  
  46.  
  47.     char charChoice;
  48.     char studentChar;
  49.  
  50.     bool showGradeMenu = true;
  51.     bool showMainMenu = true;
  52.     bool addStudent = true;
  53.     bool readLine = true;
  54.  
  55.     ifstream inputfile;
  56.     ofstream outputfile;
  57.  
  58.     while (showMainMenu != false) {
  59.         system("cls");
  60.  
  61.         cout << "----------------------------------------" << endl;
  62.         cout << "\t STUDENT GRADEBOOK \t" << endl;
  63.         cout << " 1 - Enter Student Information" << endl;
  64.         cout << " 2 - Enter Student Scores" << endl;
  65.         cout << " 3 - Grading" << endl;
  66.         cout << " 0 - Exit" << endl;
  67.         cout << "----------------------------------------" << endl;
  68.         cout << "Please select an option from the menu: ";
  69.  
  70.         cin >> mainMenuChoice;
  71.         cout << endl;
  72.  
  73.         switch (mainMenuChoice)
  74.         {
  75.             //Student Information
  76.         case 1: {
  77.             system("cls");
  78.             cout << "Student Information:" << endl;
  79.  
  80.             outputfile.open(filename, fstream::app);
  81.  
  82.             while (addStudent != false) {
  83.                 cout << "Would you like to add a student? (Y/N) ";
  84.                 cin >> studentChar;
  85.                 switch (studentChar)
  86.                 {
  87.                 case 'Y':
  88.                 case 'y': {
  89.                     system("cls");
  90.  
  91.                     cout << "Enter Student Name: ";
  92.                     cin >> fname >> lname;
  93.  
  94.                     cout << "Enter Student ID: ";
  95.                     cin >> studentID;
  96.  
  97.                     cout << "Enter Student Phone Number: ";
  98.                     cin >> phoneNumber;
  99.  
  100.                     cout << endl;
  101.  
  102.                     outputfile << studentID << "," << lname << "," << fname << "," << phoneNumber << endl;
  103.                     break; }
  104.                 case 'N':
  105.                 case 'n': {
  106.                     addStudent = false;
  107.                     cout << "Student Entry Complete. " << endl;
  108.                     system("pause");
  109.                     break; }
  110.                 default: {
  111.                     cout << "Invalid Selection. Please select an option from the menu:";
  112.                     cin >> studentChar;
  113.                     break; }
  114.                 }
  115.             }
  116.             outputfile.close();
  117.             break;
  118.         }
  119.                 //Student Scores
  120.         case 2: {
  121.             system("cls");
  122.             cout << "Student Scores:" << endl;
  123.             inputfile.open(filename);
  124.  
  125.             if (inputfile.is_open()) {
  126.  
  127.                 while (inputfile.good()) {
  128.                     inputfile >> line;
  129.                     delimiter = line.find_first_of(',');
  130.                     studentId = line.substr(0, delimiter);
  131.                     str = line.substr(delimiter + 1);
  132.  
  133.                     outLoop:
  134.                     cout << "Would you like to enter grades for student ID: " << studentId << "? (Y/N)";
  135.                     cin >> charChoice;
  136.  
  137.                     while (readLine != false) {
  138.  
  139.                         switch (charChoice)
  140.                         {
  141.                         case 'Y':
  142.                         case 'y': {
  143.                             system("cls");
  144.                             while (showGradeMenu != false) {
  145.  
  146.                                 system("cls");
  147.  
  148.                                 cout << "----------------------------------------" << endl;
  149.                                 cout << "\t Assignments \t" << endl;
  150.                                 cout << " 1 - Quizzes" << endl;
  151.                                 cout << " 2 - Homework" << endl;
  152.                                 cout << " 3 - Labs" << endl;
  153.                                 cout << " 4 - Tests" << endl;
  154.                                 cout << " 5 - Project" << endl;
  155.                                 cout << " 6 - Discussion" << endl;
  156.                                 cout << " 7 - Team Work" << endl;
  157.                                 cout << " 8 - Extra Credit" << endl;
  158.                                 cout << " 0 - Exit" << endl;
  159.                                 cout << "----------------------------------------" << endl;
  160.                                 cout << "Please select an option from the menu: ";
  161.  
  162.                                 cin >> gradeMenuChoice;
  163.                                 cout << endl;
  164.  
  165.                                 switch (gradeMenuChoice)
  166.                                 {
  167.                                 case 1: {
  168.                                     system("cls");
  169.                                     cout << "Enter the quiz scores: " << endl;
  170.                                     i = 0;
  171.                                     do {
  172.                                         cin >> quizzes[i];
  173.                                         i++;
  174.                                     } while (i < 13);
  175.  
  176.                                     for (j = 0; j < 13; j++) {
  177.                                         cout << quizzes[j] << " ";
  178.                                     }
  179.                                     cout << endl;
  180.                                     system("pause");
  181.                                     break; }
  182.                                 case 2: {
  183.                                     system("cls");
  184.                                     cout << "Enter the homework scores: " << endl;
  185.                                     i = 0;
  186.                                     do {
  187.  
  188.                                         cin >> homework[i];
  189.  
  190.                                     } while (homework[i] < 9);
  191.  
  192.                                     for (j = 0; j < 9; j++) {
  193.                                         cout << homework[j] << " ";
  194.                                     }
  195.                                     cout << endl;
  196.                                     system("pause");
  197.                                     break; }
  198.                                 case 3: {
  199.                                     system("cls");
  200.                                     cout << "Enter the lab scores: " << endl;
  201.                                     i = 0;
  202.                                     do {
  203.  
  204.                                         cin >> labs[i];
  205.  
  206.                                     } while (labs[i] < 9);
  207.  
  208.                                     for (j = 0; j < 9; j++) {
  209.                                         cout << labs[j] << " ";
  210.                                     }
  211.                                     system("pause");
  212.                                     break; }
  213.                                 case 4: {
  214.                                     system("cls");
  215.                                     cout << "Enter the test scores: " << endl;
  216.                                     i = 0;
  217.                                     do {
  218.  
  219.                                         cin >> tests[i];
  220.  
  221.                                     } while (tests[i] < 2);
  222.  
  223.                                     for (j = 0; j < 2; j++) {
  224.                                         cout << tests[j] << " ";
  225.                                     }
  226.                                     cout << endl;
  227.                                     system("pause");
  228.                                     break; }
  229.                                 case 5: {
  230.                                     system("cls");
  231.                                     cout << "Enter the project score: " << endl;
  232.                                     cin >> project;
  233.  
  234.                                     cout << project << endl;
  235.  
  236.                                     system("pause");
  237.                                     break; }
  238.                                 case 6: {
  239.                                     system("cls");
  240.                                     cout << "Enter the discussion score: " << endl;
  241.                                     cin >> discussion;
  242.  
  243.                                     cout << discussion << endl;
  244.                                     system("pause");
  245.                                     break; }
  246.                                 case 7: {
  247.                                     system("cls");
  248.                                     cout << "Enter the team work score: " << endl;
  249.                                     cin >> teamwork;
  250.  
  251.                                     cout << teamwork << endl;
  252.                                     system("pause");
  253.                                     break; }
  254.                                 case 8: {
  255.                                     system("cls");
  256.                                     cout << "Enter the extra credit score:" << endl;
  257.                                     cin >> extraCredit;
  258.  
  259.                                     cout << extraCredit << endl;
  260.                                     system("pause");
  261.                                     break; }
  262.                                 case 0: {
  263.                                     system("cls");
  264.                                     cout << "Exiting...\n" << endl;
  265.                                     showGradeMenu = false;
  266.                                     system("pause");
  267.                                     goto outLoop; }
  268.                                 default: {
  269.                                     cout << "Invalid Selection. Please select an option from the menu:";
  270.                                     cin >> gradeMenuChoice;
  271.                                     break;
  272.                                 }
  273.                                
  274.                                 }
  275.                             }
  276.                             break;
  277.                         }
  278.                         case 'N':
  279.                         case 'n': {
  280.                             system("cls");
  281.                             readLine = false;
  282.                             break;
  283.                         }
  284.                         default: {
  285.                             cout << "Invalid Selection. Please select an option from the menu:";
  286.                             cin >> charChoice;
  287.                             break;
  288.                         }
  289.                         }
  290.                     }
  291.  
  292.                 }
  293.             }
  294.             outputfile.close();
  295.             break;
  296.         }
  297.                 //Grading
  298.         case 3: {
  299.             system("cls");
  300.             cout << "Grading" << endl;
  301.             //Input Grading function here
  302.             break;
  303.         }
  304.                 //Exit
  305.         case 0: {
  306.             system("cls");
  307.             cout << "End of Program.\n" << endl;
  308.             showMainMenu = false;
  309.             break;
  310.         }
  311.         default: {
  312.             cout << "Invalid Selection. Please select an option from the menu:";
  313.             cin >> mainMenuChoice;
  314.             break;
  315.         }
  316.         }
  317.     }
  318.  
  319.     system("pause");
  320.     return 0;
  321. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement