A class of students takes a 20 question multiple-choice exam;each question has 5 choices(a,b,c,d,e)only one of them are correct.In "tests.dat"Each record of which consists of a student id, followed by a blank, followed by students 20 responses. In "answers.dat" which consists of a single record, namely the correct answers to the exam.Then It needs to produce a grade summary report like this.If the answer is correct it should put a "*" by the correct answer
student-id number correct
1231231212312 12
1233424325435 25
.... ...
question A B C D E
1 5 1 13* 3 1
2 4 7* 5 12 7
.
.
...
this is what i got so far.Thank you
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin ans,fin tests;
char key[21],id[21],response[21];
int count[20][5];
fin ans>>key;
fin tests>>>id>>response;
for(i=0,i<20,i++)
{
if(key[i] ==responses[i])
{
num correct ++;
count[i][responses[i]-'A']++;
cout<<count[i][responses[i]-'A'] &&"*"<<endl;
else(key[i] !=responses[i]){
count[i][responses[i]-'A']++;
cout<<count[i][responses[i]-'A']<<endl;
}
}
}
fin ans.open("answers.dat");
if(fin.fail("answers.dat"))
{
cout<<"Error opening stream"<<endl;
abort();
}
fin tests.open("tests.dat");
if(fin.fail("tests.dat"))
{
cout<<"Error opening stream"<<endl;
abort();
}
cout<<id<<correct<<<endl<<endl;
cout<<count<<"A B C D E"<<
<<key<<count[i][responses[i]-'A']
return 0;
}

New Topic/Question
Reply



MultiQuote



|