//All the c++ files in paste bin
////////////////////////////////////////////
http://pastebin.com/AzKPcN3v
http://pastebin.com/FrLpS0CV
http://pastebin.com/f3kYdYFW
http://pastebin.com/26h6yA3k
http://pastebin.com/cieYfDT8
http://pastebin.com/gV0sYb7q
http://pastebin.com/aT2c7bPs
http://pastebin.com/fQrjz3Sh
http://pastebin.com/sR0nrHXj
///////////////////////////////////////////////
[code]
//Main Function
#include "Student.h"
#include "Instructor.h"
#include "Exam.h"
#include "course.h"
#include <iostream>
#include <Windows.h>
#include <ctime>
using namespace std;
void main(){
//Variables Used
srand(time(0));
int tempKids[2][4][16][100];
int tempE[100];
int temp;
int tempA[100][2];
int tempB[100][2];
int tempC[100][2];
int tempD[100][2];
int tests[4]={0,0,0,0};
//Creates Classes
Students kids[2][4][16];
Exam A[4];
//Gets key for each test
A[0].getKey(tempA);
A[1].getKey(tempB);
A[2].getKey(tempC);
A[3].getKey(tempD);
//writes Exams to txt
for(int i=0;i<4;i++)
A[i].writeExam(i);
//gets Versions of the test and sets the Key for each student
for(int x=0; x<2; x++)
for(int y=0;y<4;y++)
for(int z=0;z<16;z++)
{
temp = x+(16*y)+(64*z);
kids[x][y][z].getVersion(temp);
}
//Checks the answers for all the kids
for(int x=0; x<2; x++)
for(int y=0;y<4;y++)
for(int z=0;z<16;z++)
{
switch(kids[x][y][z].getSN()){
case 0:
kids[x][y][z].checkAnswers(tempA);
kids[x][y][z].getCorrect(tempE);
A[0].findCorrect(tempE);
kids[x][y][z].checkGrade();
break;
case 1:
kids[x][y][z].checkAnswers(tempB);
kids[x][y][z].getCorrect(tempE);
A[1].findCorrect(tempE);
kids[x][y][z].checkGrade();
break;
case 2:
kids[x][y][z].checkAnswers(tempC);
kids[x][y][z].getCorrect(tempE);
A[2].findCorrect(tempE);
kids[x][y][z].checkGrade();
break;
case 3:
kids[x][y][z].checkAnswers(tempD);
kids[x][y][z].getCorrect(tempE);
A[3].findCorrect(tempE);
kids[x][y][z].checkGrade();
break;
}
}
//finds the statistics of answers for all and per section for exam class
/*for(int x=0;x<2; x++)
for(int y=0;y<4;y++)
for(int z=0;z<16;z++)
for(int i=0; i<4; i++)
{
kids[x][y][z].getCorrect(tempE);
A[i].findCorrect(tempE);
A[i].correctSec(tempE);
kids[x][y][z].checkGrade();
//gets all the correct and incorrects
for(int i=0;i<100;i++)
tempKids[x][y][z][i]=tempE[i];
//kids[x][y][z].getCorrect(tempE);
kids[x][y][z].StudentWrite(i);
}*/
//Checks grades for students
kids[1][0][3].StudentWrite(0);
kids[0][2][13].StudentWrite(1);
kids[1][1][15].StudentWrite(2);
kids[0][3][2].StudentWrite(3);
Instructor Kim;
Kim.LoadData(tempKids);
for(int i=0; i<4; i++)
A[i].WriteResults(i);
//Write Reports
//for(int i=0;i<4;i++)
//kids[2][4][i].StudentWrite(i);
course Kiwi(tests);
Kiwi.courseWrite();
Kim.writeReportIn();
}
[code]
[code]
//Course CPP
#include "course.h"
#include <iostream>
#include <fstream>
using namespace std;
course::course(int pubAnswers[4]){
a=0,b=0,c=0,d=0;
numberRightOverall=0;
for(int i=0;i<4;i++)
numberRightVersion[i]=0;
numberRightOverall=pubAnswers[0]+pubAnswers[1]+pubAnswers[2]+pubAnswers[3];
a=pubAnswers[0];
b=pubAnswers[1];
c=pubAnswers[2];
d=pubAnswers[3];
}
void course::courseWrite(){
ofstream output;
output.open("Course Overview.txt");
output<<"The number of answers correct for this course is "<<numberRightOverall<<endl;
output<<"The number of answers correct for this Test A is "<<a<<endl;
output<<"The number of answers correct for this Test B is "<<b<<endl;
output<<"The number of answers correct for this Test C is "<<c<<endl;
output<<"The number of answers correct for this Test D is "<<d<<endl;
output.close();
}
[code]
[code]
//Instructor CPP
#include "Instructor.h"
#include <iostream>
#include <fstream>
using namespace std;
Instructor::Instructor(){
instructorOneCorrect=0;
instructorTwoCorrect=0;
overallCorrect=0;
}
void Instructor::LoadData(int pubAnswers[2][4][16][100])
{
for(int x=0;x<2;x++)
for(int y=0;y<4;y++)
for(int z=0;z<16;z++)
for(int i=0;i<100;i++)
{
RawData[x][y][z][i]=pubAnswers[x][y][z][i];
}
}
///////////////////////////////////////////////////////////////////////
void Instructor::findAllCorrect(){
for(int x=0;x<2;x++)
for(int y=0;y<4;y++)
for(int z=0;z<16;z++)
for(int i=0;i<100;i++)
{
overallCorrect =+ RawData[z][y][z][i];
instructorOneCorrect =+ RawData[0][y][z][i];
instructorTwoCorrect =+ RawData[1][y][z][i];
}
}
///////////////////////////////////////////////////////////////////////
void Instructor::writeReportIn(){
ofstream output;
output.open("Instructor Reports.txt");
output<<"The total answers correct is "<<overallCorrect<<" out of 12800"<<endl;
output<<"The first instuctor's students got "<<instructorOneCorrect<<" out of 6400"<<endl;
output<<"The second instuctor's students got "<<instructorTwoCorrect<<" out of 6400"<<endl;
output.close();
}
[code]
[code]
//Exam CPP
#include "Exam.h"
#include <iostream>
#include <fstream>
#include <ctime>
using namespace std;
Exam::Exam(){
correctOver=0;
for(int x=0;x<2;x++)
for(int y=0;y<4;y++)
{
rightPerSec[x][y] = 0;
}
for(int i=0;i<100;i++)
{
key[i][0] = rand()%5;
bool distinct = false;
while(!distinct)
{
key[i][1] = rand()%5;
if(key[i][0]!=key[i][1])
distinct = true;
}
}
}
//////////////////////////////////////////////////////////////////////////////////
void Exam::writeExam(int a){
int b = a;
ofstream output;
switch(b){
case 0:
output.open("Test A.txt");
break;
case 1:
output.open("Test B.txt");
break;
case 2:
output.open("Test C.txt");
break;
case 3:
output.open("Test D.txt");
break;
}
for(int i=0;i<100;i++)
{
output<<key[i][0]<<" "<<key[i][1]<<endl;
}
output.close();
cout<<"done"<<endl;
}
/////////////////////////////////////////////////////////////////////////////////
void Exam::getKey(int pub[100][2]){
for(int i=0;i<100;i++)
{
pub[i][0] = key[i][0];
pub[i][1] = key[i][1];
}
}
/////////////////////////////////////////////////////////////////////////////////
void Exam::findCorrect(int pubAnswers[100]){
for(int x=0;x<100;x++)
{
correctOver = correctOver + pubAnswers[x];
cout<<correctOver<<endl;
}
}
////////////////////////////////////////////////////////////////////////////////
void Exam::correctSec(int pubAnswers[100]){
for(int x=0;x<2;x++)
for(int y=0;y<4;y++)
for(int z=0;z<100;z++)
{
rightPerSec[x][y] =+ pubAnswers[z];
}
}
/////////////////////////////////////////////////////////////////////////////////
void Exam::WriteResults(int a){
int b = a;
ofstream output;
switch(b){
case 0:
output.open("TestRes A.txt");
break;
case 1:
output.open("TestRes B.txt");
break;
case 2:
output.open("TestRes C.txt");
break;
case 3:
output.open("TestRes D.txt");
break;
}
output<<"The kids got "<<correctOver<<" Answers Correct"<<endl;
output.close();
cout<<"done"<<endl;
}
[code]
Hey,
I need some help with this project I can't figure out what is wrong with my code.
When I put print statements into the actual functions the output's seem to be correct however whenever the information gets written to a file the output is wrong.
Here is all the material I am basing my program off of.
/////////////////////////////////////////////////////////
http://www.scribd.com/doc/71329638/Project
http://www.scribd.com/doc/71329649/Project-Info-2
http://www.scribd.com/doc/71329652/Project-Info-3
////////////////////////////////////////////////////////
If you could help me fix this project I would very much appreciate it.