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

I have to create this program for my C++ class. I\'m using visual studio C++ 200

ID: 3627431 • Letter: I

Question

I have to create this program for my C++ class. I'm using visual studio C++ 2008.
Im having a hard time creating this program.....someone please help!!!!!

program description.

one of your professors has asked you to write a program to grade her final exams, which consist of 25 multiple-choice questions. Each question has one of four possible answers: A,B,C, or D. the exam answer key is stored in a file. the answers of the student are stored in another file, along with the student's ID number and name.

Write a program that reads the contents of the exam answer key file into one array, and the student's answers contained in another file into a second array. The program should then determine and write to an output file the following information:

* The student's ID number and name.
*A list of the questions missed by the student, showing the correct answer and the incorrect answer provided by the student for each missed question.
*The total number of questions missed.
*The percentage of questions answered correctly. This can be calculated as
(Correctly answered questions / total number of questions) * 100
*the letter grade based on the scale below:

percentage Grade
90-100 A
80-89 B
70-79 C
60-69 D
0-59 F

the program must prompt the user for the name of each file, it should continue to ask the user for the name of a file until a valid one is provided. The contents of the output file must be nicely formatted and the percentage of the questions answered correctly should be displayed with one decimal place.

your program must have at a minimum the following functions:

* openAnswerKeyFile : Prompts the user for the name of the exam answer key file, and opens the file for input. this function doesnt read the contents of the file.

*openStudentFile: Prompts the user for the name of the file containing the student's answers, and opens the file input. This function doesnt read the contents of the file.

* openOutputFile: prompts the user for the name of the output file, and opens the file for output. This function doesn't write the results to the file.

*readAnswerKey: Reads the contents of the exam answer key file into an array and closes the file after it has been read.

*readStudentFIle: Reads the contents of the file containing the student's answers. The answers should be read into an array, and the Id number and name into separate variables.
The file should be closed after it has been read.

*CheckExam: Compares the student's answers with the answer key and records the questions missed in a bool array. for instance, say the bool array is called: missedQuestions. If the student misses question 5 , then missedQuestion[4] is set to true. (Remember that the subscript of the first element of an erray is zero.) In general, if missedQuestion[i] = true, then question (i+ 1) is incorrect. Otherwise, if missedQuestion[i] = false, then question (i+1) is correct.

*writeResults: Writes the results to the output file and closes the file when it finishes writing.

*writeMissedQuestionsList: Writes a list of the questions missed by the student, showing the correct answer and the incorrect answer provided by the student for each missed question to the output file. This function should be called by writeResults.

* computeLetterGrade: Computes and returns the letter grade on the student's percentage score and the grade scale provided above.

The prototypes for the functions that open the files are:

Void openAnswerKeyFile (ifstream & answerFile);
void openStudentFile (ifstream & studentFile);
void openOutputFile(ofstream & outFIle);

Im having a hard time creating this program.....someone please help!!!!!

Explanation / Answer

please rate - thanks

any questions message me

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void openAnswerKeyFile(ifstream&);
void openStudentFile(ifstream&);
void openOutputFile(ofstream&);
void readAnswerKeyFile(ifstream&, char[]);
void readStudentFile(ifstream&, char[],string,string);
void CheckExam(char[],char[],bool[]);
void writeResults(ofstream&,string,string,bool[],char[],char[]);
int writeMissedQuestionsList(ofstream&,bool[],char[],char[]);
char computeLetterGrade(double);


int main()
{ifstream key, ans;
ofstream out;
char answerKey[25];
char student[25];
bool missed[25];
string id,name;
openAnswerKeyFile(key);
openStudentFile(ans);
openOutputFile(out);

readAnswerKeyFile(key,answerKey);
readStudentFile(ans,student,id,name);
CheckExam(answerKey,student,missed);
writeResults(out,id,name,missed,answerKey,student);
return 0;
}
void openAnswerKeyFile(ifstream& key)
{char filename[80];
cout<<"Enter name of answer key file: ";
cin>>filename;
key.open(filename);
}
void openStudentFile(ifstream& ans )
{char filename[80];
cout<<"Enter name of student file: ";
cin>>filename;
ans.open(filename);
}
void openOutputFile(ofstream& out)
{char filename[80];
cout<<"Enter name of output file: ";
cin>>filename;
out.open(filename);
}

void readAnswerKeyFile(ifstream& key, char a[])
{int i;
for(i=0;i<25;i++)
key>>a[i];
key.close();
}
void readStudentFile(ifstream& ans,char a[],string id,string name)
{ans>>id;
ans.ignore(256,' ');
getline(ans,name);
for(int i=0;i<25;i++)
   ans>>a[i];
ans.close();
}

void CheckExam(char k[],char s[],bool m[])
{int i;
for(i=0;i<25;i++)
    if(k[i]==s[i])
         m[i]=false;
    else
         m[i]=true;
}

void writeResults(ofstream& out,string id ,string name,bool missed[] ,
                  char key[] ,char stu[])
{int wrong=0,i;
double pct;
out<<"Student id:   "<<id<<endl;
out<<"Student name: "<<name<<endl;
wrong=writeMissedQuestionsList(out,missed,key,stu);
pct=(25.-wrong)/25.*100;
out<<"Percentage:    "<<setprecision(2)<<fixed<<pct<<endl;
out<<"Grade:         "<<computeLetterGrade(pct)<<endl;
out.close();
}
int writeMissedQuestionsList(ofstream& out,bool missed[],char key[],char stu[])
{int wrong=0,i;
out<<"missed questions ";
out<<"number correct student answer answer ";
for(i=0;i<25;i++)
    if(missed[i])
       {wrong++;
       out<<i+1<<" "<<key[i]<<" "<<stu[i]<<endl;
       }
if(wrong==0)
     out<<"no questions missed ";
else
   out<<wrong<<" questions missed ";
return wrong;
}
char computeLetterGrade(double p)
{if(p>=90)
     return 'A';
else if(p>=80)
      return 'B';
else if(p>=70)
      return 'C';
else if(p>=60)
      return 'D';
else
      return 'F';
}