Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

SANJIVANI RURAL EDUCATION SOCIETY’S

SANJIVANI K. B. P. POLYTECHNIC

Certificate
THIS IS TOCERTIFY THAT THE PROJECT REPORT ENTITLED

“QUIZ GAME USING SWING AND EVENT HANDLING”


ADVANCED JAVA PROGRAMMING – JPR[22517]
SUBMITTED BY

Mr. Ponde Prathamesh (47)


UNDE OUR SUPERVISION AND GUIDENCE FOR PARTIAL FULLFILLMENT OF THE

REQUIREMENT FOR DIPLOMA IN COMPUTER TECHNOLOGY

AFFILIATED TO

MAHARASHTRA STATE BOARD OF TECHINAL , MUMBAI

FOR ACADAMIC YEAR

2022 - 23

PROF. MS. R. S. PATIL MR. G. N. JORVEKAR


PROJECT GUIDE HOD

1 page
INTRODUCTION

A Quiz Game is an engaging and interactive form of entertainment or educational activity that
challenges participants' knowledge and quick thinking. It typically involves a series of
questions presented to players, who must provide answers within a certain time limit. Quiz
games can take various forms, including traditional trivia quizzes, online quiz apps, TV game
shows, or even educational tools.
Here are some key elements and features that make up a quiz game:
1. Questions:Quiz games consist of a set of questions that cover a wide range of topics, from
general knowledge to specific subjects or themes. These questions can be multiple-choice,
true or false, open-ended, or any other format that requires a response from the participants.
2. Participants:Quiz games can be played by individuals or teams, depending on the format.
Participants compete to answer questions correctly and accumulate points.
3. Scoring:Correct answers earn participants points, while incorrect answers may result in
point deductions or no points awarded. The scoring system can vary, with some games
awarding more points for more challenging questions.
4. Time Limit:Most quiz games impose a time limit for answering each question, adding an
element of urgency and excitement to the gameplay. The time limit can vary depending on
the complexity of the question.
5. Leaderboards:Many quiz games feature leaderboards that display the rankings of
participants based on their scores. This competitive aspect encourages players to strive for
the top position.
6. Categories:Quiz games often have questions organized into categories or topics, allowing
players to choose the areas they are most comfortable with or interested in.
7. Lifelines:In some quiz games, players may be given lifelines, such as "ask the audience,"
"phone a friend," or "50/50," which provide additional help in answering questions.

2 page
PROGRAM

import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/*<applet code="QuizGame.class"width="500"height="500"></applet> */

public class QuizGame extends Applet implements ActionListener {


private String[] questions = {
"1) What is the capital of France?\n",
"2) Which planet is known as the Red Planet?\n",
"3) How many continents are there on Earth?\n",
"4) How many district are there in maharashtra?\n",
"5) How many bits are in a single IP address?\n",
"6) Port number for Http is?\n",
"7) How many states are there in India?\n",
"8) What is pin code of vaijapur?\n",
"9) Which is the capital of India?\n",
"10) Which is the capital of maharashtra?\n",
"11) Who is the Prime Minister of India?\n"

};

private String[] answers = {


"Paris",
"Mars",
"7",

3 page
"36",
"32",
"80",
"29",
"423701",
"Delhi",
"Mumbai",
"Narendra Modi"

};

private int currentQuestion = 0;


private int score = 0;

private Label questionLabel;


private TextField answerField;
private Button submitButton;
private Label scoreLabel;

public void init() {


questionLabel = new Label(questions[currentQuestion]);
answerField = new TextField(20);
submitButton = new Button("Submit");
scoreLabel = new Label("Score: " + score);

submitButton.addActionListener(this);

add(questionLabel);
add(answerField);
add(submitButton);

4 page
add(scoreLabel);
}

public void actionPerformed(ActionEvent e) {


String userAnswer = answerField.getText();
if (userAnswer.equalsIgnoreCase(answers[currentQuestion])) {
score++;
}

currentQuestion++;
if (currentQuestion < questions.length) {
questionLabel.setText(questions[currentQuestion]);
answerField.setText("");
} else {
questionLabel.setText("Quiz completed!");
answerField.setEnabled(false);
submitButton.setEnabled(false);
}

scoreLabel.setText("Score: " + score +"/11");


}
}

5 page
EXECUTION OF PROGRAM

OUTPUT OF CODE

RUNTIME VISIT OF OUTPUT.

6 page
2) CORRECT ANSWER PUT IN BOX.

3) WRONG ANSWER PUT IN BOX.

• SCORE IS 10 /11
• WORNG ANSWER : 1
• CORRECT ANSWERS : 10
• TOTAL QUSTIONS : 11

7 page
CONCLUSION

In conclusion, quiz games are a versatile and engaging form of entertainment and education
that have captured the imagination of people around the world. They provide a wide range of
benefits and experiences, from entertainment and competition to learning and knowledge
reinforcement.

REFERANCES

https://www.youtube.com/youtube
https://www.google.co.in
https://www.w3schools.com

8 page

You might also like