Advertisement
nitrojector

Untitled

Nov 18th, 2024
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <vector>
  5. #include <string>
  6. #include <cstdlib>
  7. //********************
  8. // You may NOT add other #includes nor try to call other library functions
  9. // not given in the above headers/libraries. You have to write other desired
  10. // functionality yourself
  11. //********************
  12. using namespace std;
  13.  
  14.  
  15. struct StudentPrediction {
  16. string name;
  17. int low;
  18. int high;
  19. int actual;
  20. };
  21.  
  22.  
  23. class GradeCheck {
  24. public:
  25. GradeCheck(int maxScore);
  26. ~GradeCheck();
  27. bool readPredictions(const char* predictionFilename);
  28. bool addActualScore(string name, int score);
  29. double getPercentAccurate() const;
  30. private:
  31. int maxScore_;
  32. vector<StudentPrediction> predictions_;
  33. // ==== Task 1: ADD NECESSARY DATA MEMBERS HERE =====
  34. };
  35.  
  36.  
  37. GradeCheck::GradeCheck(int maxScore) {
  38. // ==== Task 2a: Any necessary code here ====
  39. }
  40.  
  41. GradeCheck::~GradeCheck() {
  42. // ==== Task 2b: Any necessary code here ====
  43. }
  44.  
  45.  
  46. bool GradeCheck::readPredictions(const char* predictionFilename) {
  47. // ==== Task 3: Your code here ====
  48. }
  49.  
  50. bool GradeCheck::addActualScore(string name, int score) {
  51. // ==== Task 4: Your code here ====
  52. }
  53.  
  54. // Must run in O(1) time
  55. double GradeCheck::getPercentAccurate() const
  56. { // ==== Task 5: Your code here ====
  57. }
  58.  
  59. //**************************************
  60. // Do not change these 2 lines and don't
  61. // add any lines between them and main()
  62. //**************************************
  63. #ifndef AUTO_TEST
  64. #define AUTO_TEST
  65. int main(int argc, char* argv[])
  66. {
  67. if(argc < 3) {
  68. cout << "Usage: " << argv[0] << " <maxScore> <roster file>" << endl;
  69. return 1;
  70. }
  71. // ==== Task 6a: Add your code here to read maxScore from the command line ====
  72.  
  73. GradeCheck gc(maxScore);
  74. if(gc.readPredictions(argv[2])) {
  75. cout << "Error during init" << endl;
  76. return 1;
  77. }
  78. while(true) {
  79. cout << "Enter name and actual score: " << endl;
  80. string name;
  81. int actual;
  82. cin >> name >> actual;
  83. // ==== Task 6b: Add the condition to halt the program on the appropriate input
  84.  
  85. gc.addActualScore(name, actual);
  86. }
  87. cout << fixed << setprecision(2);
  88. cout << "Number of correct predictions: " << gc.getPercentAccurate() << endl;
  89. return 0;
  90. }
  91. //****************************************
  92. // Do not change the following line
  93. //****************************************
  94. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement