A teacher put three bonus questions on a test and awarded 5 extra points to anyone who answered all three bonus questions correctly and no extra points otherwise. Assume that the boolean variables bonusOne, bonusTwo, and bonusThree indicate whether a student has answered the particular question correctly. Each variable was assigned true if the answer was correct and false if the answer was incorrect.
Which of the following code segments will properly update the variable grade based on a student’s performance on the bonus questions?
1)
if (bonusOne && bonusTwo && bonusThree)
grade += 5;
2)
if (bonusOne || bonusTwo || bonusThree)
grade += 5;
3)
if (bonusOne)
grade += 5;
if (bonusTwo)
grade += 5;
if (bonusThree)
grade += 5;
A) I only
B) II only
C) III only
D) I and III
E) II and III