7.0k views
1 vote
Assuming that a user enters 68 as the score, what is the output of the following code snippet? int score = 68; if (score < 50) { System.out.println("F"); } else if (score >= 50 || score < 55) { System.out.println("D"); } else if (score >= 55 || score < 65) { System.out.println("C"); } else if (score >= 65 || score < 75) { System.out.println("B"); } else if (score >= 75 || score < 80) { System.out.println("B+"); } else { System.out.println("A"); } D C B A

1 Answer

0 votes

Answer:

D

Step-by-step explanation:

Using if in this way will validate one by one, and finding a true value will not validate the rest of "else if"

score = 68

if (score < 50) --> print "F"

  • 68 < 50 --> false

else if (score >= 50 OR score < 55) --> print "D"

  • 68 > = 50 TRUE .... (The OR operator displays a record if any of the conditions separated by OR is TRUE)

As this condition is true the system will not validate the other conditions

User Pdross
by
3.8k points