Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.81 KB | None | 0 0
  1. #include "Student.h"
  2. #include <iostream>
  3. #include <fstream>
  4. #include <ctime>
  5. #include <Windows.h>
  6. using namespace std;
  7.  
  8. Students::Students(){
  9.     keyNumber=0;
  10.     grade=0;
  11.     studentNumber=0;
  12.     for(int i = 0; i <100; i++)
  13.     totalCorrect[i]=2;
  14.     //Seed Random Function
  15.    
  16.     //Has student randomly guess questions
  17.     ofstream output;
  18.     output.open("Constructor Output.txt",ios::app);
  19.     for(int i=0;i<100;i++)//working
  20.         {
  21.             answers[i]=rand()%5;
  22.             output<<answers[i]<<endl;
  23.         }
  24.     output<<"////////"<<endl;
  25.     output.close();
  26.    
  27.  
  28.    
  29.     //for(int i =4; i<10; i++)
  30.         //cout<<answers[i]<<"//////////////////"<<endl;
  31. }
  32.  
  33. void Students::getVersion(int studentNumber)
  34. {
  35.     //Sets the keyNumber for the student to determine what test it will be checked against
  36.     keyNumber=studentNumber%4; // working
  37.    
  38.     ofstream output;
  39.     output.open("getversions output.txt",ios::app);
  40.     output<<keyNumber<<endl;
  41.     output.close();
  42. }
  43. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  44. void Students::checkAnswers(const int a[100][2]){
  45.     //Variable to hold the test answers
  46.     /*int theKey[100][2];
  47.  
  48.     for(int i=0;i<100;i++)
  49.         {
  50.             theKey[i][0] = a[i][0];
  51.             theKey[i][1] = a[i][1];
  52.         }  
  53.     */
  54.     //checks students answers to key
  55.     ofstream output;
  56.     output.open("Check Answers output.txt",ios::app);
  57.     for(int i=0;i<100;i++)//NOT !!!  WORKINGGGGG
  58.     {
  59.         if(answers[i]==a[i][0]||answers[i]==a[i][1])
  60.         {
  61.             totalCorrect[i]=1;
  62.         }
  63.         else
  64.         {
  65.             totalCorrect[i]=0;
  66.         }
  67.         output<<totalCorrect[i]<<endl;
  68.     }
  69.     output<<"///////"<<endl;
  70.     output.close();
  71.    
  72.    
  73.    
  74. }
  75. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  76. void Students::checkGrade()
  77. {
  78.     ofstream output;
  79.     output.open("checkGrades output.txt",ios::app);
  80.     //Calculates the students correct answers
  81.     for(int a=0;a<100;a++)//working
  82.     {
  83.         grade = grade + totalCorrect[a];
  84.         output<<grade<<endl;
  85.     }
  86.     output<<"///////"<<endl;
  87.     output.close();
  88.        
  89.    
  90.  
  91. }
  92. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  93. void Students::returnAnswers(int pubAnswers[]){
  94.     //Used to return the students answers so that the main function and access them
  95.    
  96.     for(int i=0;i<100;i++)//un-used
  97.     {
  98.         pubAnswers[i]=answers[i];
  99.     }
  100.    
  101.        
  102. }
  103. void Students::printGrades(int pubAnswers[]){
  104.     ofstream output;
  105.     output.open("Grades.txt");
  106.     for(int i=0;i<100;i++)///Come back to us used at the moment
  107.     {
  108.         if(-1>grade<70)
  109.         {
  110.             output<<"Student "<<i<<"'s Grade is a A"<<endl;
  111.         }
  112.         if(69>grade<75)
  113.         {
  114.             output<<"Student "<<i<<"'s Grade is a D"<<endl;
  115.         }
  116.         if(74>grade<80)
  117.         {
  118.             output<<"Student "<<i<<"'s Grade is a C"<<endl;
  119.         }
  120.         if(79>grade<90)
  121.         {
  122.             output<<"Student "<<i<<"'s Grade is a B"<<endl;
  123.         }
  124.         if(89>grade<101)
  125.         {
  126.             output<<"Student "<<i<<"'s Grade is a A"<<endl;
  127.         }
  128.     }
  129.    
  130.     output.close();
  131. }
  132. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  133. int Students::getSN(){
  134.     return keyNumber;
  135. }
  136. /////////////////////////////////////////////////////////////////////////////////////////////////////////
  137. void Students::getCorrect(int pubAnswers[100]){
  138.     for(int i=0;i<100;i++)//working
  139.         pubAnswers[i] = totalCorrect[i];
  140.    
  141. }
  142. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  143. int Students::getGrade(){
  144. return grade;
  145. }
  146. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  147. void Students::StudentWrite(){
  148.    
  149.     ofstream output;
  150.         output.open("Student correct.txt",ios::app);
  151.            
  152.     for(int i=0;i<100;i++)
  153.     {
  154.        
  155.         output<<answers[i]<<" "<<totalCorrect[i]<<endl;
  156.     }
  157.     output<<grade<<endl;
  158.         output<<"/////////////////////////////"<<endl;
  159.     output.close();
  160.    
  161.     cout<<"done"<<endl;
  162. }
  163.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement