Write a java application that is including a three-question multiple choice quiz about Java programming language. Each question must have four possible answers (numbered 1 to 4). Also, ask user to type 0 to exit the test. [Assume that a user enters only integers 1,2,3,4, or 0].
Firstly, display a message that this quiz includes three questions about the Java programming language and display that each question has four possible answers.
If the answer is correct for the given question, display that the answer is correct.
If the answer is not correct for the given question, display that the answer is wrong.
If the user answers three questions correctly, display “Excellent”, if two, display “very good”, if one or fewer, display “It is time to start to learning Java”.
After that, ask user whether he or she wants to play again [you can use a boolean variable].
If user inputs true, start the game again. If user inputs false, then display a goodbye message and finish the game [Assume that user enters only true or false]. name the file MyTest.java
Solution : To implement the java quiz application , we will take the integer input values from the user using the scanner class.We will make use of a while loop which runs the quiz until the user inputs the value true or else the program the terminates .If at any instant the user wants to exit the quiz he or she must press 0, then the break statement will be executed and the progam will terminate.
Code :
import java.util.Scanner;
public class MyTest {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
boolean flag = true;
while (flag) {
System.out.println("This quiz contains three questions about java programming language and each question has four possible answers.");
int correct = 0;
System.out.println("Question 1: Which component is used to compile, debug and execute java program?\n" +
"1) JVM\n" +
"2) JDK\n" +
"3) JIT\n" +
"4) JRE\n" +
"enter 0 to exit the test");
int userInput = s.nextInt();
if (userInput == 2) {
System.out.println("Answer is correct");
correct++;
} else if (userInput == 0) {
break;
} else {
System.out.println("Answer is wrong");
}
System.out.println("Question 2: Which statement is true about java?\n" +
"1) Platform independent programming language\n" +
"2) Platform dependent programming language\n" +
"3) Code dependent programming language\n" +
"4) Sequence dependent programming language\n" +
"enter 0 to exit the test");
userInput = s.nextInt();
if (userInput == 1) {
System.out.println("Answer is correct");
correct++;
} else if (userInput == 0) {
break;
} else {
System.out.println("Answer is wrong");
}
System.out.println("Question 3: Which of the following is a valid declaration of an object of class Box?\n" +
"1) obj = new Box();\n" +
"2) Box obj = new Box;\n" +
"3) Box obj = new Box();\n" +
"4) new Box obj\n" +
"enter 0 to exit the test");
userInput = s.nextInt();
if (userInput == 3) {
System.out.println("Answer is correct");
correct++;
} else if (userInput == 0) {
break;
} else {
System.out.println("Answer is wrong");
}
if (correct == 3) {
System.out.println("Excellent!");
}
if (correct == 2) {
System.out.println("Very good!");
}
if (correct <= 1) {
System.out.println("It is time to start learning java!");
}
System.out.println("Do you want to play again?");
flag = s.nextBoolean();
if (flag) {
continue;
} else if (flag == false) {
System.out.println("Goodbye");
break;
}
}
}
}


Output 1 :

Output 2 :

Write a java application that is including a three-question multiple choice quiz about Java programming language....
Java Programming Write a program that will help a student learn multiplication. Use SecureRandom object to produce two positive integers between 1 and 20. The program should then prompt the user with a question (use a sentinel-controlled loop), such as: How much is 10 times 11? The student then inputs the answer. If the answer is correct display the message “very good” and ask another question. If the answer is wrong to display the message “no, please try again” and...
Java Programming Use a one-dimensional array to solve the following program. Write an application that inputs six numbers [Keep the numbers in an array]. The numbers must be between 20 and 200, inclusive. If the number is not between 20 and 200, ask for another input. When a number is entered, display the number only if it is not a duplicate of a number already entered. If it is a duplicate of a number already entered, display a message that...
x= Suppose you are building a program for teaching kids' math. Write a java program the does the following: 1. Ask the user if he/she wants to sign-up a. If yes continue to step 2 b. If no Display the message "Thank you, Have a nice Day 2. Ask the user to enter a username. 3. Ask the user to enter a password with at least 8 characters long 4. Write a method with the following header: public static Boolean...
Programming Assignment Objective Write a Java program that utilizes multiple classes. Write a Java program that utilizes inheritance in a practical manner. Problem: Quiz Bowl Your high school quiz bowl team has been losing its edge and needs to find a method to improve. Knowing that you are a savvy programmer, your coach asks you to write a program that the team members can use to hone their skills. Quiz Bowl questions come in three varieties: True/False Multiple Choice (variable...
see below:
You will be creating a personal quiz that will provide a grade depending on the responses given. The quiz should contain at least three questions of the true/false or multiple-choice nature. You should select only one type of question to use. These questions should originate from Comprehension Check in your textbook (noting the chapter and page number) These questions and the correct answer identifier should be stored in a text file. A second table should contain the possible...
I have to use java programs using netbeans. this
course is introduction to java programming so i have to write it in
a simple way using till chapter 6 (arrays) you can use (loops ,
methods , arrays)
You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...
Write a GUI-based Java application that implements the "Math Game" shown below. The program asks the user to enter the answer of multiplying two one-digit random integers. If the user enters a correct answer, a message will be displayed at the bottom of the frame, and the text field will be cleared. If the user enters a wrong answer, a message will be displayed at the bottom of the frame asking for another answer. If the user...
What is wrong with my code? Trying to fix the Boolean situation and it keeps skipping my boolean question and repeating. import java.util.Scanner; public class MyTest{ public static void main (String [] args){ Scanner input = new Scanner(System.in); System.out.println("JAVA QUIZ"); System.out.println("This quiz includes three questions about the Java Programming Language."); System.out.println("Each question has 4 possible answers. (numbered 1,2,3,4)"); System.out.println("Enter 0 to exit the test.");...
CS 1102 Unit 5 – Programming Assignment In this assignment, you will again modify your Quiz program from the previous assignment. You will create an abstract class called "Question", modify "MultipleChoiceQuestion" to inherit from it, and add a new subclass of "Question" called "TrueFalseQuestion". This assignment will again involve cutting and pasting from existing classes. Because you are learning new features each week, you are retroactively applying those new features. In a typical programming project, you would start with the...
Write In JAVA: Part 1 The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to produce two positive one-digit integers (you will need to look up how to do this). The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s...