Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- #include <vector>
- #include <string>
- #include <cstdlib>
- //********************
- // You may NOT add other #includes nor try to call other library functions
- // not given in the above headers/libraries. You have to write other desired
- // functionality yourself
- //********************
- using namespace std;
- struct StudentPrediction {
- string name;
- int low;
- int high;
- int actual;
- };
- class GradeCheck {
- public:
- GradeCheck(int maxScore);
- ~GradeCheck();
- bool readPredictions(const char* predictionFilename);
- bool addActualScore(string name, int score);
- double getPercentAccurate() const;
- private:
- int maxScore_;
- vector<StudentPrediction> predictions_;
- // ==== Task 1: ADD NECESSARY DATA MEMBERS HERE =====
- };
- GradeCheck::GradeCheck(int maxScore) {
- // ==== Task 2a: Any necessary code here ====
- }
- GradeCheck::~GradeCheck() {
- // ==== Task 2b: Any necessary code here ====
- }
- bool GradeCheck::readPredictions(const char* predictionFilename) {
- // ==== Task 3: Your code here ====
- }
- bool GradeCheck::addActualScore(string name, int score) {
- // ==== Task 4: Your code here ====
- }
- // Must run in O(1) time
- double GradeCheck::getPercentAccurate() const
- { // ==== Task 5: Your code here ====
- }
- //**************************************
- // Do not change these 2 lines and don't
- // add any lines between them and main()
- //**************************************
- #ifndef AUTO_TEST
- #define AUTO_TEST
- int main(int argc, char* argv[])
- {
- if(argc < 3) {
- cout << "Usage: " << argv[0] << " <maxScore> <roster file>" << endl;
- return 1;
- }
- // ==== Task 6a: Add your code here to read maxScore from the command line ====
- GradeCheck gc(maxScore);
- if(gc.readPredictions(argv[2])) {
- cout << "Error during init" << endl;
- return 1;
- }
- while(true) {
- cout << "Enter name and actual score: " << endl;
- string name;
- int actual;
- cin >> name >> actual;
- // ==== Task 6b: Add the condition to halt the program on the appropriate input
- gc.addActualScore(name, actual);
- }
- cout << fixed << setprecision(2);
- cout << "Number of correct predictions: " << gc.getPercentAccurate() << endl;
- return 0;
- }
- //****************************************
- // Do not change the following line
- //****************************************
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement