I am almost done, I am haveing a problem with the code below.
I am trying to fill one array from an input file that conatins the 6 test answers for the test that is displayed by another function. Then I try to fill another array with answers from the user. Finally I compare the to arrays and return a score.
I am << what data fills the test_answer array and it is 0's when in fact there is proper answer data. As well, when the user is prompted to enter an answer, when he enters the first answer the quersor hangs. After I hit enter a few times, a incorrect slection warning from the main goes into a continual loop. This is based of a fraction class I made.
I am almost done this project and I mus present it today. I have worked very hard to get it done and this last problem is killing me.
Code:
double get_answers()
{
ifstream answers;
fraction user_answers[6], test_answers[6];
fraction f1, f2;
//int checks[6];
int score=0;
answers.open("testanswers.in");
if(answers.fail())
{
cout<<"The test answers are not available" <<endl;
exit(1);
}
for(int x = 0; x<6; x++)
{
answers>>test_answers[x];
cout<<test_answers[x];
}
for(int y = 0; y<6; y++)
{
cout<<"Enter your answer for Question "<<y+1<<": ";
cin>>user_answers[y];
}
for(int i = 0; i<6; i++)
{
f1 = user_answers[i];
f2 = test_answers[i];
if(f1 == f2)
score++;
//else
//score = score;
}
return (score/6.0);
}
I am << what data fills the test_answer array and it is 0's when in fact there is proper answer data. As well, when the user is prompted to enter an answer, when he enters the first answer the quersor hangs. After I hit enter a few times, a incorrect slection warning from the main goes into a continual loop. This is based of a fraction class I made.
I am almost done this project and I mus present it today. I have worked very hard to get it done and this last problem is killing me.
Comment