Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the problem: CorrectAnswers.txt (the correct answers to the exam) is thi

ID: 3820253 • Letter: T

Question

This is the problem:

CorrectAnswers.txt (the correct answers to the exam) is this picture


The student's answers are listed in this picture


My professor would like it laid out in the following fashion:


If anything in any of the pictures are unclear, comment and I'll try to clarify. Thank you!

objective Reading Data Files Project This is a variation of programming challenge 7.11 described in Gaddis on page 451 One of your profeseors has asked you to rite a program to grade her final exams which consist of 20 multiple choix q uestions. Each question has one of four poesible answers: A, B, C, or D. The file CorrectAnswers txt contains the corrent answers for all of the questions with each answer written on a separate line. The first line oontains the answer to the first question, the second line contains the answer to the second question, and so forth. rite a program that reads the conten of the CorroxtAnswers txt file into a dar array, aud then reads the contents of another file that contains astm dent's answers into a second char array. The program should determine the mmber of questions that the student missed and then display the following A list of the questious missed by the slkwing the correct an- swer and the incorrect answer kd by the student for ean Provid question. The total numb of ions missed The perceutaRe of the questions answered oorrectly. If the ntage of corrently answered questions is 70 or greater the program should indicate that the stadert wead the exami. otherwise it Nhould indicate that the students failed the exam.

Explanation / Answer

Here is the code for you:

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
#include <cmath>
using namespace std;

const int MAX_SIZE = 20;

class ExamData
{
    public:
        char correctAnswers[MAX_SIZE];
        char studentAnswers[MAX_SIZE];
        int numOfQuestions;
        int studentNumCorrect;
};
void printHeader(string, string, string, string);
int readData(string, char[]);
void scoreExams(ExamData);
void printResults(ExamData);

int main()
{
    // Call the splash screen function
printHeader("Your Name", "CMPSC 121", "Date", "Program Description");
ExamData midterm;
scoreExams(midterm);
printResults(midterm);
return 0;
}
void scoreExams(ExamData exam)
{
    exam.numOfQuestions = readData("CorrectAnswers.txt", exam.correctAnswers);  
    int numAnswers = readData("StudentAnswers.txt", exam.studentAnswers);
    exam.studentNumCorrect = 0;
    for(int i = 0; i < exam.numOfQuestions; i++)
        if(exam.correctAnswers[i] == exam.studentAnswers[i])
            exam.studentNumCorrect++;
}
int readData(string fileName, char inArray[])
{
    ifstream inStream;
    int size = -1;
    char tempChar;
    inStream.open(fileName);
    if(!inStream.fail())
    {
       while(inStream >> tempChar)
       {
          size++;
          inArray[size] = tempChar;
       }
    }
    else
    {
       cout << "File: " << fileName << " failed to open ";
       exit(1);
    }
    return size+1;
}
void printHeader(string name, string course, string dueDate, string description) {
// PRINTHEADER printHeader(string, string, string, string) is the
// function used to hide away the splash screen
//
// Name: Prof. Adams
// Course: CMPSC 121
// Date: 12 March 2017
//
  
// Print the splash screen
cout << endl;
cout << name << endl;
cout << course << endl;
cout << dueDate << endl;
cout << description << endl;
cout << endl;
  
return;
}
void printResults(ExamData exam)
{
    cout << "Correct Answers: ";
    for(int i = 0; i < exam.numOfQuestions; i++)
        cout << exam.correctAnswers[i] << " ";
    cout << endl;
   
    cout << "Student Answers: ";
    for(int i = 0; i < exam.numOfQuestions; i++)
        cout << exam.studentAnswers[i] << " ";
    cout << endl;
    cout << "Percentage of score: " <<    exam.studentNumCorrect / (double)exam.numOfQuestions * 100 << "%" << endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote