P4
P4
Scanner;
class Question {
String questionText;
String[] options;
int correctAnswer; // index (0 to 3)
if (questions[i].isCorrect(answer)) {
System.out.println("Correct! ?");
score++;
} else {
System.out.println("Wrong ?. Correct answer: " +
questions[i].options[questions[i].correctAnswer]);
}
System.out.println("--------------------------------------");
}
System.out.println("Quiz Completed!");
System.out.println("Your Score: " + score + " out of " + questions.length);
displayResult();
}
if (percentage == 100) {
System.out.println("Outstanding! ??");
} else if (percentage >= 80) {
System.out.println("Excellent Work! ??");
} else if (percentage >= 50) {
System.out.println("Good Job! ??");
} else {
System.out.println("Try again. Practice makes perfect! ??");
}
}
}