Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. //
  2. // Created by JONLOL on 10/19/2019.
  3. //
  4. #include "TestGrader.h"
  5.  
  6.  
  7.  
  8. void TestGrader::setKey(string correct[])
  9. {
  10.  
  11.     for (int x = 0; x < 20; x++)
  12.     {
  13.         answers[x] = correct{x};
  14.     }
  15. }
  16.  
  17. void TestGrader::grade(string test[])
  18. {
  19.  
  20.     int correct = 0;
  21.     int incorrect = 0;
  22.     int counter = 0;
  23.  
  24.     for (int x = 0; x < 20; x++)
  25.     {
  26.  
  27.         if (test[x] == answers[x])
  28.         {
  29.             correct +=1;
  30.             counter +=1;
  31.         }
  32.  
  33.         else if (test[x] != answers[x])
  34.         {
  35.             incorrect += 1;
  36.         }
  37.     }
  38.  
  39.     if (counter >=15)
  40.     {
  41.         cout << "You passed!" << endl;
  42.     }
  43.     else
  44.     {
  45.         cout << "You failed!" << endl;
  46.     }
  47.  
  48.     cout << "You correctly got: " << correct << " correct answers and: " << incorrect << "incorrect." << endl;
  49.  
  50.     cout << "The questions you got wrong were: " << endl;
  51.     for (int x = 0; x < 20; x++)
  52.     {
  53.         if (test[x] != answers[x])
  54.         {
  55.             cout << x + 1 << endl;
  56.         }
  57.     }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement