Java Project
Java Project
Source code :
import java.util.Scanner;
scanner.nextLine();
System.out.println("\Question 3: Which is used to find and fix bugs in the Java
programs.?");
System.out.println("a) JVM");
System.out.println("b) JBD");
System.out.println("c) JDK");
System.out.print("Your answer: ");
String answer3 = scanner.nextLine();
if (answer3.equalsIgnoreCase("b")) {
score++;
feedback.append("Question 3: Correct\n");
} else {
feedback.append("Question 3: Incorrect\n");
}
if(score >= 3) {
System.out.println("Great job, " + name + "! Your score is good!");
} else {
System.out.println("Keep practicing, " + name + ". You can do better!");
}
}
}.
Output :
a) Import
b) Package
c) Export
Your answer: a
Question 2: What is 2 + 2?
Your answer: 4
Question 3: Which is used to find and fix bugs in the Java programs.?
a) JVM
b) JBD
c) JDK
Your answer: b
a) 5
b) 6
c) Compilation Error
Your answer: b
Incorrect!
Question 5: What is the keyword used to indicate the beginning of a class in Java?
Your answer: b
Incorrect!
Name: Prince
Feedback:
Question 1: Correct
Question 2: Correct
Question 3: Correct
Question 4: Incorrect
Question 5: Incorrect
Explanation :
The program uses the `Scanner` class to receive input from the user, allowing the user to input
their name, roll number, and answers to the quiz questions.
Variables: It declares variables to store the user's name (`name`), roll number (`rollNo`), quiz
score (`score`), and feedback (`feedback`). These variables are used throughout the program to
capture and manipulate data.
String Manipulation : The program uses various string manipulation methods, such as
`equalsIgnoreCase()`, to compare the user's answer with the correct answer case-insensitively.
User Interaction : The program interacts with the user by prompting them to input their name,
roll number, and answers to quiz questions. It also provides feedback and personalized
messages based on the user's input and performances.