Advertisement
krames12

Grade Projector (helping with friends homework)

Mar 24th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.89 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<conio.h>
  4. #include<stdio.h>
  5. #include<limits>
  6. #include<vector>
  7.  
  8. using namespace std;
  9. using std::vector;
  10.  
  11. //Table Pieces
  12. const unsigned char V = (char)186;
  13. const unsigned char H = (char)205;
  14. const unsigned char BL = (char)185;
  15. const unsigned char BR = (char)204;
  16. const unsigned char M = (char)206;
  17. const unsigned char DM = (char)203;
  18. const unsigned char UM = (char)202;
  19. const unsigned char C1 = (char)201;
  20. const unsigned char C2 = (char)187;
  21. const unsigned char C3 = (char)188;
  22. const unsigned char C4 = (char)200;
  23.  
  24. int main()
  25. {
  26.     //Declare variables for use in the program; A's are Assignments
  27.     //and P's are Projects
  28.     double result1 = 0;
  29.  
  30.     vector<float> assignments;
  31.     vector<float> projects;
  32.  
  33.     //Table Variables
  34.     const char sep = ' ';
  35.     const int letWidth = 12;
  36.     const int pointNeed = 15;
  37.     const int percNeed = 19;
  38.  
  39.     //Table Result Variables
  40.     double Apoint;
  41.     double Bpoint;
  42.     double Cpoint;
  43.     double Dpoint;
  44.     double Aperc;
  45.     double Bperc;
  46.     double Cperc;
  47.     double Dperc;
  48.  
  49.     //Scores
  50.     int int1 = 2;
  51.     int int2 = 900;
  52.     int int3 = 800;
  53.     int int4 = 700;
  54.     int int5 = 600;
  55.  
  56.  
  57.  
  58.     //Title
  59.     printf("GRADE PROJECTOR \n");
  60.     printf("------------------------------------------------------- \n");
  61.  
  62.  
  63.     //Prompts for user input
  64.  
  65.     for (int i = 1; i <= 10; i++)
  66.     {
  67.         int enteredValue = 0;
  68.  
  69.         cout << "Please try again and enter the correct 'Assignment#" << i << "' score" << endl;
  70.         cin >> enteredValue;
  71.  
  72.         while (1) {
  73.             if (cin.fail())
  74.             {
  75.                 cin.clear();
  76.                 cin.ignore(numeric_limits<streamsize>::max(), '\n');
  77.                 cout << "Please try again and enter the correct 'Assignment#" << i << "' score" << endl;
  78.                 cin >> enteredValue;
  79.             }
  80.             else {
  81.                 assignments.push_back(enteredValue);
  82.                 break;
  83.             }
  84.         }
  85.     }
  86.  
  87.     for (int i = 1; i <= 2; i++)
  88.     {
  89.         int enteredValue = 0;
  90.  
  91.         cout << "Please try again and enter the correct 'Project#" << i << "' score" << endl;
  92.         cin >> enteredValue;
  93.  
  94.         while (1) {
  95.             if (cin.fail())
  96.             {
  97.                 cin.clear();
  98.                 cin.ignore(numeric_limits<streamsize>::max(), '\n');
  99.                 cout << "Please try again and enter the correct 'Assignment#" << i << "' score" << endl;
  100.                 cin >> enteredValue;
  101.             }
  102.             else {
  103.                 projects.push_back(enteredValue);
  104.                 break;
  105.             }
  106.         }
  107.     }
  108.  
  109.     //The total of all the assignments and projects
  110.     for (unsigned int a = 0; a < 10; a++) {
  111.         result1 += assignments[a];
  112.     }
  113.    
  114.     for (unsigned int p = 0; p < 2; p++) {
  115.         result1 += projects[p];
  116.     }
  117.  
  118.  
  119.     //Display results of total so far
  120.     printf("\n");
  121.     printf("------------------------------------------------------- \n");
  122.     printf("TOTAL POINTS SO FAR: "),
  123.         printf("%.2lf", result1);
  124.  
  125.  
  126.     //The points needed for whichever grade
  127.     Apoint = (int2 - result1);
  128.     Bpoint = (int3 - result1);
  129.     Cpoint = (int4 - result1);
  130.     Dpoint = (int5 - result1);
  131.  
  132.  
  133.     //The percentage needed for whichever grade
  134.     Aperc = (Apoint / int1);
  135.     Bperc = (Bpoint / int1);
  136.     Cperc = (Cpoint / int1);
  137.     Dperc = (Dpoint / int1);
  138.  
  139.  
  140.     //Display results in table
  141.     cout << endl << endl;
  142.     cout << C1 << H << H << H << H << H << H << H << H << H << H << H << H << DM << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << DM << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << C2 << endl;
  143.     cout << V << setw(letWidth) << setfill(sep) << "FINAL GRADE" << V << setw(pointNeed) << setfill(sep) << "POINTS NEEDED" << V << setw(percNeed) << setfill(sep) << "PERCENTAGE NEEDED" << " " << V << endl;
  144.     cout << BR << H << H << H << H << H << H << H << H << H << H << H << H << M << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << M << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << BL << endl;
  145.     cout << V << setw(letWidth) << setfill(sep) << "A" << V << setw(pointNeed) << setfill(sep) << Apoint << V << setw(percNeed) << setfill(sep) << Aperc << "%" << V << endl;
  146.     cout << V << setw(letWidth) << setfill(sep) << "B" << V << setw(pointNeed) << setfill(sep) << Bpoint << V << setw(percNeed) << setfill(sep) << Bperc << "%" << V << endl;
  147.     cout << V << setw(letWidth) << setfill(sep) << "C" << V << setw(pointNeed) << setfill(sep) << Cpoint << V << setw(percNeed) << setfill(sep) << Cperc << "%" << V << endl;
  148.     cout << V << setw(letWidth) << setfill(sep) << "D" << V << setw(pointNeed) << setfill(sep) << Dpoint << V << setw(percNeed) << setfill(sep) << Dperc << "%" << V << endl;
  149.     cout << C4 << H << H << H << H << H << H << H << H << H << H << H << H << UM << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << UM << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << H << C3 << endl;
  150.  
  151.     //Project 3 Requirement to not fail
  152.     cout << endl << endl;
  153.     cout << "Any 'Project#3' grade that scores below " << Dperc << "% will resuilt in failing the semester" << endl;
  154.  
  155.     _getch();
  156.     return 0;
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement