0% found this document useful (0 votes)
10 views2 pages

JVM Project

cjjcfukncgklbchjn vhkm vjk n khfgikvjhdtikhgtknvujkkjvhulkgtuikjhfyikvfykknvhikjteeyiijgfyujbjjcggttggggggftujbgdr ghjhfyykgfyjbvftjh gujghyibvghjgwqrybvukb vhjhkiijgryjb

Uploaded by

hypebest04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

JVM Project

cjjcfukncgklbchjn vhkm vjk n khfgikvjhdtikhgtknvujkkjvhulkgtuikjhfyikvfykknvhikjteeyiijgfyujbjjcggttggggggftujbgdr ghjhfyykgfyjbvftjh gujghyibvghjgwqrybvukb vhjhkiijgryjb

Uploaded by

hypebest04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

Scanner;

public class QuizProgram {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// User information input


System.out.println("Welcome to the Quiz Program!");
System.out.print("Enter your name: ");
String studentName = scanner.nextLine();
System.out.print("Enter your course: ");
String course = scanner.nextLine();
System.out.println("Welcome, " + studentName + "! Let's start the quiz for " + course + ".");

// Array to hold questions, options, and correct answers


String[][] quizData = {
// Solar System Questions
{"Which planet is known as the Red Planet?", "A) Venus", "B) Jupiter", "C) Mars",
"D) Saturn", "C"},
{"What is the largest planet in our solar system?", "A) Venus", "B) Jupiter", "C) Mars",
"D) Saturn", "B"},
{"Which planet is closest to the Sun?", "A) Venus", "B) Mercury", "C) Mars", "D)
Earth", "B"},
{"What is the hottest planet in our solar system?", "A) Venus", "B) Mercury", "C)
Mars", "D) Earth", "A"},
// Philippines History Questions
{"Who is considered the national hero of the Philippines?", "A) Emilio Aguinaldo",
"B) Andres Bonifacio", "C) Jose Rizal", "D) Ferdinand Marcos", "C"},
{"In what year did the Philippines gain independence from Spain?", "A) 1896", "B)
1898", "C) 1901", "D) 1946", "B"},
{"Who was the first president of the Philippines?", "A) Emilio Aguinaldo", "B)
Manuel Quezon", "C) Sergio Osmena", "D) Ferdinand Marcos", "A"},
{"What is the longest river in the Philippines?", "A) Pasig River", "B) Cagayan River",
"C) Agusan River", "D) Pampanga River", "B"},
// Physical Health Questions
{"What is the recommended daily water intake for adults?", "A) 1 liter", "B) 2 liters",
"C) 3 liters", "D) 4 liters", "B"},
{"How many hours of sleep are recommended for adults each night?", "A) 4-5 hours",
"B) 6-7 hours", "C) 8-9 hours", "D) 10-11 hours", "C"}
};
int score = 0; // Initialize score counter

// Quiz loop
for (int i = 0; i < quizData.length; i++) {
String[] question = quizData[i];
System.out.println("\nQuestion " + (i + 1) + ": " + question[0]);
System.out.println("Options:");
for (int j = 1; j < question.length - 1; j++) {
System.out.println(question[j]);
}

// User input
System.out.print("Your answer (A/B/C/D): ");
String userChoice = scanner.nextLine();

// Display user answer


System.out.println("Your answer: " + userChoice);

// Check answer
if (userChoice.equalsIgnoreCase(question[5])) {
System.out.println("Correct!");
score++;
} else {
System.out.println("Incorrect. The correct answer is: " + question[5]);
}
}

// Display final score


System.out.println("\nQuiz completed!");
System.out.println("Your score: " + score + "/" + quizData.length);

scanner.close();
}
}

You might also like