Requirements: Use a class, an array, file input/output.
Goal: Compare the student answers (.txt) to the answer key (.txt) and output the students name, missed questions and overall score to a .txt.
Firstly, is my design decent?
What I need to do now is to compare student answers to the answer key. I've been struggling trying to think of a pattern or design to follow to implement the array. Any guidance is appreciated.
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
class Test {
private:
double score_; // Total score
string StudentAnswer_;
double QuestionValue_; // 1 point for correct answer, 0 for omitted, 1/4 deducted for incorrect
string QuestionType_; // 9 multiple choice, 8 T/F, 3 fill in the blank
public:
Test(); // default constructor
// Setters (mutators)
void SetStudentAnswer_(string answer);
void SetQuestionType_(string type);
void SetQuestionValue_(double value);
// Getters (accessors)
string GetStudentAnswer_();
string GetQuestionType_();
double GetQuestionValue_();
};
Test::Test() { // Constructor
score_ = 0;
StudentAnswer_ = " ";
QuestionValue_ = 0;
QuestionType_[20]; // 20 total test questions
}
// Set functions
void Test::SetStudentAnswer_(string answer) {
StudentAnswer_ = answer;
}
void Test::SetQuestionValue_(double value) {
QuestionValue_ = value;
}
void Test::SetQuestionType_(string type) {
QuestionType_ = type;
}
// Get functions
string GetStudentAnswer_(string answer) {
return answer;
}
double GetQuestionValue_(double value) {
return value;
}
string GetQuestionType_(string type) {
return type;
}
int main() {
Test DoTest; // Object
int data; // temp storage
ifstream inStudentAnswers; // Open student answers and answer key then compare them
ifstream inAnswerKey;
ofstream outStudentAnswers; // Output student name, missed questions and overall test grade
inStudentAnswers.open("studentanswers.txt");
inAnswerKey.open("answerkey.txt");
outStudentAnswers.open("studentresults.txt");
if (inStudentAnswers.is_open() && inAnswerKey.is_open()) {
}
} // end main