Okay, so I know that you guys aren't my own personal programmers but I was wondering if you could help me out a bit here. I work as a teachers assistant while I'm going to school. I know a bit of C++ and was trying to make a basic program to check answers with.
The first part of the program works fine to test the answers against the key, however the second part is what I'm having issues with. I'm trying to find how many students answered what question so I don't have to count them by hand, but I cannot seem to get this down.
What I really need is to be able to print them out like so:
question A B C D E
1 1 12 3 5 7
and so on.
I know I'm probably going to need a nested for loop, but I've been banging my head on this all night. Any help would be appreciated.
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void main(){
int numstud=0, numcorrect, i;
string key, id, responses;
ifstream keyfin, studfin;
keyfin.open("answers.dat");
studfin.open("tests.dat");
keyfin >> key;
studfin >> id >> responses;
cout << setw(5) << "Student-Id's" << setw(20) << "# Correct" << endl << endl;
while(!studfin.eof())
{
numstud++;
numcorrect=0;
for(i=0; i<20; i++){
if(responses[i] == key[i])
{
numcorrect++;
}
}
cout << id << setw(20) <<numcorrect << endl;
studfin >> id >> responses;
}
studfin >> id >> responses;
int col[20][5]={0}, j=0;
char ch;
studfin >> id >> responses;
cout << "Question" << setw(10) << "A" << setw(5) << "B" << setw(5) << "C" << setw (5) << "D" << setw(5) << "E";
while (!studfin.eof())
{
for(i=0; i<responses.length(); i++)
{
col[i++][responses[i-'a'] ++];
}
}
}