Hi,
please use [ CODE ] tags to make the code readable.
The problem is that you overwrite the intermediate results. Say you have the numbers 5, 2, 1. Since quizScore1 > quizScore2, you get highestScore = 5 in the first "if" statement. However, in the second statement you have quizScore2 > quizScore3, so highestScore is changed to 2 (and that's the final value).
You'd need to have a single "if-else-if-else-if..." statement.
But you can simplify a code a lot if you first assume quizScore1 to be the highest value and then check each value if it's greater:
Code:
highestScore = quizScore1;
if (quizScore2 > highestScore)
highestScore = quizScore2;
if (quizScore3 > highestScore)
highestScore = quizScore3;
And a more intelligent (and object-oriented) approach would consist of defining a "max" method and using that:
Code:
int max(int m, int n) {
if (m >= n)
return m;
else
return n;
}
... snip ...
highestScore = max(max(quizScore1, quizScore2), quizScore3);
Of course Java already has such a method built-in (Math.max), but I guess you're not supposed to use that?