Advertisement
Guest User

Untitled

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