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KICAgICAgICBpbnQgc2NvcmUgPSAwOwoKICAgICAgICBmb3IgKGludCBpID0gMDsgaSAmbHQ7IHF1ZXN0aW9ucy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4ocXVlc3Rpb25zW2ldKTsKICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogJmx0OyBvcHRpb25zW2ldLmxlbmd0aDsgaisrKSB7CiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oKGogKyAxKSArICZxdW90Oy4gJnF1b3Q7ICsgb3B0aW9uc1tpXVtqXSk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoJnF1b3Q7RW50ZXIgdGhlIG51bWJlciBvZiB5b3VyIGFuc3dlcjogJnF1b3Q7KTsKICAgICAgICAgICAgaW50IHVzZXJBbnN3ZXIgPSBzY2FubmVyLm5leHRJbnQoKSAtIDE7CgogICAgICAgICAgICBpZiAob3B0aW9uc1tpXVt1c2VyQW5zd2VyXS5lcXVhbHMoYW5zd2Vyc1tpXSkpIHsKICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigmcXVvdDtDb3JyZWN0ISZxdW90Oyk7CiAgICAgICAgICAgICAgICBzY29yZSsrOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCZxdW90O0luY29ycmVjdC4gVGhlIGNvcnJlY3QgYW5zd2VyIGlzICZxdW90OyArIGFuc3dlcnNbaV0pOwogICAgICAgICAgICB9CgogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oKTsKICAgICAgICB9CgogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigmcXVvdDtZb3VyIGZpbmFsIHNjb3JlIGlzICZxdW90OyArIHNjb3JlICsgJnF1b3Q7IG91dCBvZiAmcXVvdDsgKyBxdWVzdGlvbnMubGVuZ3RoKTsKICAgIH0KfQoK
import java.util.Scanner;
public class QuizProgram {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] questions = {
"What is the capital of France?",
"Who painted the Mona Lisa?",
"What is the largest planet in our solar system?"
};
String[][] options = {
{"Berlin", "Paris", "London", "Madrid"},
{"Leonardo da Vinci", "Michelangelo", "Raphael", "Caravaggio"},
{"Earth", "Saturn", "Jupiter", "Uranus"}
};
String[] answers = {"Paris", "Leonardo da Vinci", "Jupiter"};
int score = 0;
for (int i = 0; i < questions.length; i++) {
System.out.println(questions[i]);
for (int j = 0; j < options[i].length; j++) {
System.out.println((j + 1) + ". " + options[i][j]);
}
System.out.print("Enter the number of your answer: ");
int userAnswer = scanner.nextInt() - 1;
if (options[i][userAnswer].equals(answers[i])) {
System.out.println("Correct!");
score++;
} else {
System.out.println("Incorrect. The correct answer is " + answers[i]);
}
System.out.println();
}
System.out.println("Your final score is " + score + " out of " + questions.length);
}
}