Ok, so I have most of the code working but I've been up for over 24 hours and I just cannot seem to get the test score to come out. Here's my code, hopefully someone with fresh eyes can spot my error, I know it has to be something simple (it always is).
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
string filename;
ifstream inFile, powFile;
const int SIZE = 20;
char firstArray[SIZE];
char secondArray[SIZE];
int missed, avg, total, count;
missed = 0;
avg = 0;
total = 0;
inFile.open("c:\\correctanswers.txt");
powFile.open("c:\\studentanswers.txt");
for (count = 0; count < SIZE; count++)
inFile >> firstArray[count];
for (count = 0; count < SIZE; count++)
powFile >> secondArray[count];
for (count = 0; count < SIZE; count++)
{
if (firstArray[count] != secondArray[count])
{
cout << "Missed question #" << count;
cout << " Students answer: " << secondArray[count];
cout << " Correct answer: " << firstArray[count] << endl;
missed++;
}
else;
}
total = SIZE - missed;
cout << "Number of correct answers: " << total << endl;
avg = total / SIZE; //right in here i think
cout << fixed << showpoint << setprecision(2);
cout << "Percentage answered correctly: " << avg << "%" << endl;
if (avg >= 70)
cout << "The student passed the exam." << endl;
else
cout << "The student failed the exam." << endl;
return 0;
}