Advertisement
Guest User

Exam CPP

a guest
Nov 2nd, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #include "Exam.h"
  2. #include <iostream>
  3. #include <fstream>
  4. #include <ctime>
  5. using namespace std;
  6.  
  7. Exam::Exam(){
  8.     correctOver=0;
  9.     for(int x=0;x<2;x++)
  10.     for(int y=0;y<4;y++)
  11.         {
  12.             rightPerSec[x][y] = 0;
  13.         }
  14.    
  15.         for(int i=0;i<100;i++)
  16.         {
  17.             key[i][0] = rand()%5;
  18.             bool distinct = false;
  19.             while(!distinct)
  20.             {
  21.                 key[i][1] = rand()%5;
  22.                 if(key[i][0]!=key[i][1])
  23.                     distinct = true;
  24.             }
  25.         }
  26. }
  27. //////////////////////////////////////////////////////////////////////////////////
  28. void Exam::writeExam(int a){
  29.     int b = a;
  30.     ofstream output;
  31.     switch(b){
  32.     case 0:
  33.         output.open("Test A.txt");
  34.         break;
  35.     case 1:
  36.         output.open("Test B.txt");
  37.         break;
  38.     case 2:    
  39.         output.open("Test C.txt");
  40.         break;
  41.     case 3:    
  42.         output.open("Test D.txt");
  43.         break;     
  44.     }      
  45.     for(int i=0;i<100;i++)
  46.     {
  47.         output<<key[i][0]<<"    "<<key[i][1]<<endl;
  48.     }
  49.     output.close();
  50.     cout<<"done"<<endl;
  51. }
  52. /////////////////////////////////////////////////////////////////////////////////
  53. void Exam::getKey(int pub[100][2]){
  54.     for(int i=0;i<100;i++)
  55.     {
  56.         pub[i][0] = key[i][0];
  57.         pub[i][1] = key[i][1];
  58.     }
  59.    
  60. }
  61. /////////////////////////////////////////////////////////////////////////////////
  62. void Exam::findCorrect(int pubAnswers[100]){
  63.     for(int x=0;x<100;x++)
  64.         {
  65.             correctOver = correctOver + pubAnswers[x];
  66.             cout<<correctOver<<endl;
  67.         }
  68. }
  69. ////////////////////////////////////////////////////////////////////////////////
  70. void Exam::correctSec(int pubAnswers[100]){
  71.     for(int x=0;x<2;x++)
  72.         for(int y=0;y<4;y++)
  73.             for(int z=0;z<100;z++)
  74.             {
  75.                 rightPerSec[x][y] =+ pubAnswers[z];
  76.             }
  77. }
  78. /////////////////////////////////////////////////////////////////////////////////
  79. void Exam::WriteResults(int a){
  80.    
  81.     int b = a;
  82.     ofstream output;
  83.     switch(b){
  84.     case 0:
  85.         output.open("TestRes A.txt");
  86.         break;
  87.     case 1:
  88.         output.open("TestRes B.txt");
  89.         break;
  90.     case 2:    
  91.         output.open("TestRes C.txt");
  92.         break;
  93.     case 3:    
  94.         output.open("TestRes D.txt");
  95.         break;     
  96.     }      
  97.    
  98.         output<<"The kids got "<<correctOver<<" Answers Correct"<<endl;
  99.    
  100.     output.close();
  101.     cout<<"done"<<endl;
  102.  
  103. }
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement