Using Java develop a GUI based simple quiz game. The questions and answers of the game will be stored in a text file (i.e. our database). On the first page the users will be provided with some instructions on how to play the game and next button to go to the next page. On the next page will be a start button to either start the game and an exit button to exit the game. Once the game starts there will be approx. 10-20 general knowledge question with four options to select from. The options will have radio buttons so there can only be one answer to the given question. Once all the questions are answered the total score shall be displayed along with an option to play again or exit the game.
Please run this as java application and check the result.
package javaapplication1;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class ChoiceGame implements ActionListener {
JFrame fr;
JRadioButton rbtn1, rbtn2, rbtn3, rbtn4;
JButton btn1, btn2,btn3;
JLabel lb1, lb2;
ButtonGroup bg;
String ques[] = {"World Cancer Day is observed on which
day?",
"World Radio Day is celebrated on:",
"Abraham Lincoln's Birthday is celebrated on..",
"In India, Taj Mahotsav is celebrated on which day?",
"20 February is observed as...",
"Central Excise Day is observed on:",
"What is the theme of World Cancer Day 2020?",
"13 February is celebrated as birth anniversary of which
personality?",
"World NGO Day is observed on...",
" On which day, International Mother Language Day is
celebrated?"};
String op1[] = {"3 February", "11 February","10 February","18
February","Word Scout Day","22 February","Not beyond us","Sarojini
Naidu","20 February","15 February"};
String op2[] = {"4 February", "13 February","12 February","20
February","World Day of Social Justice","23 February","We can, I
can","Mother Teresa","24 February","18 February"};
String op3[] = {"6 February", "15 February","14 February","22
February","World NGO Day","24 February","I Am and I
Will","Anandibai Gopalrao Joshi","27 February","21
February"};
String op4[] = {"9 February", "18 February","16 February","None of
the above","World Wildlife Day","25 February","None of the
above","Reita Faria Powell","29 February","25 February"};
String ans[] = {"4 February", "13 February","12 February","18
February","World Day of Social Justice","24 February","I Am and I
Will","Sarojini Naidu","27 February","21 February"};
int cn = 0;
ChoiceGame() {
fr = new JFrame();
fr.setLayout(null);
fr.setSize(600, 600);
Container c = fr.getContentPane();
c.setBackground(Color.cyan);
lb1 = new JLabel(ques[0]);
lb1.setBounds(50, 50, 1000, 30);
fr.add(lb1);
lb1.setFont(new Font("chiller", Font.BOLD, 30));
rbtn1 = new JRadioButton(op1[0]);
rbtn1.setBounds(100, 120, 100, 30);
fr.add(rbtn1);
rbtn2 = new JRadioButton(op2[0]);
rbtn2.setBounds(350, 120, 100, 30);
fr.add(rbtn2);
rbtn3 = new JRadioButton(op3[0]);
rbtn3.setBounds(100, 200, 100, 30);
fr.add(rbtn3);
rbtn4 = new JRadioButton(op4[0]);
rbtn4.setBounds(350, 200, 100, 30);
fr.add(rbtn4);
bg = new ButtonGroup();
bg.add(rbtn1);
bg.add(rbtn2);
bg.add(rbtn3);
bg.add(rbtn4);
rbtn1.addActionListener(this);
rbtn2.addActionListener(this);
rbtn3.addActionListener(this);
rbtn4.addActionListener(this);
btn1 = new JButton("Sumbit");
btn1.setBounds(100, 400, 100, 30);
fr.add(btn1);
btn2 = new JButton("Next");
btn2.setBounds(250, 400, 100, 30);
fr.add(btn2);
btn1.addActionListener(this);
btn2.addActionListener(this);
fr.setVisible(true);
}
public static void main(String s[]) {
new ChoiceGame();
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btn1) {
String en = "";
if (rbtn1.isSelected()) {
en = rbtn1.getText();
}
if (rbtn2.isSelected()) {
en = rbtn2.getText();
}
if (rbtn3.isSelected()) {
en = rbtn3.getText();
}
if (rbtn4.isSelected()) {
en = rbtn4.getText();
}
if (en.equals(ans[cn])) {
JOptionPane.showMessageDialog(null, "Correct Answer ! score :
10!!!");
} else {
JOptionPane.showMessageDialog(null, "Wrong Answer! Please try
again!!!");
}
}
if (e.getSource() == btn2) {
cn++;
lb1.setText(ques[cn]);
rbtn1.setText(op1[cn]);
rbtn2.setText(op2[cn]);
rbtn3.setText(op3[cn]);
rbtn4.setText(op4[cn]);
}
}
}
Using Java develop a GUI based simple quiz game. The questions and answers of the game...
How to use textbox, radio buttons, checkbox, and dropdown list to make up a quiz of 20 questions ... How to use textbox, radio buttons, checkbox, and dropdown list to make up a quiz of 20 questions ONLY using JavaScript. No Jquery. When the quiz starts, the questions don't appear all at once, it will display one question at a time with a next button, until the last question with Submit button. Finally, when the quiz is finished, display the...
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,...
Using Dr Java Objective: Create a game of video poker with a graphical user interface (GUI). The player should start with $100, and then the system deals out 5 playing cards. After the player sees the cards they are then asked to wager $10, $20, $50, or $100. Next the user picks which cards they wish to throw away, and then the system deals more cards in their place. Once this has concluded money are awarded by these criteria: Nothing...
java In this project you will implement a trivia game. It will ask random trivia questions, evaluate their answers and keep score. The project will also have an administrative module that will allow for managing the question bank. Question bank management will include adding new questions, deleting questions and displaying all of the questions, answers and point values. 2. The project can be a GUI or a menu based command line program. 3. Project details 1. Create a class to...
Java Help References Mailings Review View No Spacing Heading 1 Heading 2 Normal For following questions, please provided your solutions for each of the questions in a separate Word document to include screenshots of execution of the code. Using IntellJ IDE, which can be downloaded at the following address https://www.jetbrains.com/idea/downloadf#eection windows. Be sure to select the Community version. Create a project using the proper naming convention a. b. Create the code to build a GUI and should have the following...
Question 1 (Marks: 50 Develop a Java GUI application that will produce an investment report based on various criteria, such as investment amount, investment type and term. On the form create two text fields, one to capture the customer name and (10) Q.1.1 another to capture the amount to invest. Also create a combo box for the user to select the investment type which will be moderate or aggressive. Finally add three radio buttons for the user to select the...
java In this project you will implement a trivia game. It will ask random trivia questions, evaluate their answers and keep score. The project will also have an administrative module that will allow for managing the question bank. Question bank management will include adding new questions, deleting questions and displaying all of the questions, answers and point values. 2. The project can be a GUI or a menu based command line program. 3. Project details 1. Create a class to...
Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application. Person: The Person class should implement serializable interface. It contains the following: Person's first name (String) Person's last name (String) Person's id number Person's date of birth (Date) public String toString(): This method method...
Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game simulates a card game where the cards a placed face down and the player flips over pairs of cards in an attempt to find matching cards. Program Procedure Display a 4x4 grid of “face down” cards. Assign the letters A through H randomly to the cards in pairs. Allow the user to click on a card to “flip” it over and...
I need the answers of the 5 discussion questions CASE #3 Game Not Over, Not Yet Although their expertise lies in creating games, it's definitely Then, it's the discipline of understanding the customers by using serious business for the video game industry. The computer and focus groups to pinpoint desires and likes and dislikes. And it's the video game industry has struggled over the last couple of years discipline of sharing best practices and technologies through the as game makers...