Solved

Mar 23, 2013 at 11:49pm
Solved
Last edited on Mar 26, 2013 at 9:34pm
Mar 24, 2013 at 4:40am
studentFile >> studentAnswers[count])

What does this mean right shift bit instruction do within the while condition?
Last edited on Mar 24, 2013 at 4:41am
Mar 24, 2013 at 5:16am
Well, you never do anything with your student grade variable... You set it equal to 0 and never do anything to it after that
Mar 24, 2013 at 6:04pm
 
studentFile >> studentAnswers[count])


This is supposed to read the values listed in the studentFile "StudentAnswers.txt" and put those values into the studentAnswers array. I'm not entirely sure if this is how it's supposed to work, though.

And for the studentGrade variable, I've tried doing this:

1
2
3
4
5
6
	if (sameAnswer)
		cout << "The answer is correct.\n";
	studentGrade + 5;
	else
	
		cout << "The answer is wrong.\n";


But that doesn't do anything with the variable.
Mar 24, 2013 at 8:54pm
This right here is your problem

1
2
3
4
5
6
7
8
9
10
11
12
	while (sameAnswer && count < QUESTIONS)
	{
		if (studentAnswers[count] != correctAnswers[count])
			sameAnswer = false;
		count++;
	}
	if (sameAnswer)
		cout << "The answer is correct.\n";
	studentGrade + 5; //I copyed from this from your second post
	else
	
		cout << "The answer is wrong.\n";


This couldn't posible work because you did not assign the result to anything, use += operator.
studentGrade + 5;
And it should be inside the while loop, so that you could perfor this check:
1
2
	if (studentGrade >= 70)
		cout << "Congratulations! You passed." << endl;


And in your while loop shouldn't check sameAnswer, because your way it stops at the first wrong answer (that is why (quoting you)"this part of the code is just flat out being ignored") and since you want to check all answers you don't need this variable at all.
while (sameAnswer && count < QUESTIONS)

Insted of your if statement in the while loop (which by thw way is in your code just an extension of condition for the while loop), you should use == operator and if it is true do studentGrade += 5; that would give you 5 points for each correct answer.

And this code is just sencless if you put it outside the while loop
1
2
3
4
5
6
	if (sameAnswer)
		cout << "The answer is correct.\n";
	
	else
	
		cout << "The answer is wrong.\n";
Topic archived. No new replies allowed.