
Untitled
By: a guest on
Nov 2nd, 2011 | syntax:
C++ | size: 2.44 KB | hits: 86 | expires: Never
#include "Exam.h"
#include <iostream>
#include <fstream>
#include <ctime>
using namespace std;
Exam::Exam(){
correctOver=0;
rightPerSecOne=0;
rightPerSecTwo=0;
int rightPerSecOne = 0;
int rightPerSecTwo = 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::correctSecOne(int pubAnswers[100]){
for(int z=0;z<100;z++)
{
rightPerSecOne = rightPerSecOne + pubAnswers[z];
}
}
/////////////////////////////////////////////////////////////////////////////////
void Exam::correctSecTwo(int pubAnswers[100]){
for(int z=0;z<100;z++)
{
rightPerSecTwo = rightPerSecTwo + 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"<<"out of 3200"<<endl;
output<<"Section 1 got "<<rightPerSecOne<<" out of 1600 correct"<<endl;
output<<"Section 2 got "<<rightPerSecTwo<<" out of 1600 correct"<<endl;
output.close();
cout<<"done"<<endl;
}