0% found this document useful (0 votes)
8 views18 pages

Java

Uploaded by

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

Java

Uploaded by

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

A Project Report

on
“QUIZ USING BASIC JAVA”
Submitted for Partial Fulfillment of the Requirements

For the award of the degree of

Bachelor of Technology

in

Electronics & Computer Engineering (ECM)

by

JITTA YASHWANTH REDDY (21311A1975),

RATNALA SAIGANESH (21311A1976),

Y MOHANA LAXMI (21311A1977)

Under the Guidance of

Ms. N SWAPNA
Assistant Professor

Department of Electronics & Computer Engineering

Sreenidhi Institute of Science & Technology

2022-23

i
DEPARTMENT OF ELECTRONICS & COMPUTER
ENGINEERINGSREENIDHI INSTITUTE OF SCIENCE &
TECHNOLOGY (AUTONOMOUS)

CERTIFICATE

This is to certify that the Project work entitled “Quiz using Basic Java”,
submitted by Jitta Yashwanth Reddy, Ratnala Sai Ganesh, Y Mohana Laxmi
bearing Roll No. 21311A1975, 21311A1976, 21311A1977 towards partial
fulfilment for the award of Bachelor Degree in Electronics & Computer Engineering from
Sreenidhi Institute of Science & Technology, Ghatkesar, Hyderabad, is a record of
bonafide workdone by him/ her. The results embodied in the work are not submitted to any
other University or Institutefor award of any degree or diploma.

Ms. N SWAPNA Dr. D. Mohan


Assistant Professor HOD of ECM
ECM Dept.

(iii
)
DECLARATION

This is to certify that the work reported in the present Project Work titled “Quiz using Basic
Java” is a record work done by us in the Department of Electronics and Computer
Engineering, Sreenidhi Institute of Science and Technology, Yamnampet,Ghatkesar.

The report is based on the project work done entirely by us and not copied from any other
source.

J YASHWANTH REDDY (21311A1975)

R SAI GANESH (21311A1976)

Y MOHANA LAXMI (21311A1977)

(iii
)
ACKNOWLEDGMENT

We would like to express our sincere appreciation to everyone who supported us in completing
this project. Firstly, we extend our gratitude to Ms. N Swapna, Assistant Professor, who served
as our guide and provided us with valuable guidance, support, and timely suggestions throughout
the project.

We are grateful to Dr. D. Mohan, Head of the ECM Department at Sreenidhi Institute of Science
and Technology, Ghatkesar, for his encouragement and valuable suggestions that helped us
undertake this project. We would also like to thank Dr. T.Ch. Siva Reddy, Principal, and Mr.
C.V. Tommy, Executive Director, for their support throughout the project.

Finally, we would like to extend our thanks to our families, friends, and the teaching and non-
teaching staff who helped us directly or indirectly in this endeavor. We are grateful for their
constant support and encouragement.

J YASHWANTH REDDY (21311A1975)

R SAI GANESH (21311A1976)

Y MOHANA LAXMI (21311A1977)

(iv)
ABSTRACT

This abstract provides an overview of a quiz application developed using basic Java
programming concepts. The application aims to facilitate the creation and administration
of quizzes, allowing users to test their knowledge in various subjects. The quiz application
employs object-oriented programming principles and incorporates fundamental Java
features such as classes, inheritance, and polymorphism. It utilizes a console-based
interface to interact with the user, providing a straightforward and intuitive experience.

The application enables users to create multiple-choice quizzes with customizable


questions and answer options. It supports a wide range of question types, including
true/false, multiple-choice, and fill-in-the-blank. Each quiz can have a predefined number
of questions and can be assigned a time limit for completion. To enhance user
engagement, the quiz application includes features like scoring and feedback. After
completing a quiz, users receive an immediate score and feedback on their performance.
The application also offers the option to review answers and see correct solutions for each
question.

Furthermore, the quiz application includes functionalities for quiz management. It allows
users to create, edit, and delete quizzes, as well as add or remove questions from existing
quizzes. The application stores quiz data in a file or database, ensuring persistent storage
and easy retrieval of quiz information.

(v)
TABLE OF CONTENTS

No. Topics Page No.


Title (i)
Certificate (ii)
Declaration (iii)
Acknowledgement (iv)
Abstract (v)
List of Figures (viii)
1 Description 1
Design and implementation 2
2
2.1 Design 2
2.2 System Setup 2
2.3 Program 3
2.4 Implementation 5
2.5 Limitations 5
3 Results and Outputs 6
4 Conclusion and future advancements 10
5 References 11

LIST OF FIGURES

Figure No. Figure Names Page No.

1.1 System Design 2


3.1 Result 1 5
3.2 Result 2 5
3.3 Result 3 6
3.4 Result 4 6
3.5 Result 5 6
3.6 Result 6 7
3.7 Result 7 8
3.8 Result 8 8
3.9 Result 9 8
3.10 Result 10 9
3.11 Final Result 9

(viii)
CHAPTER 1

DESCRIPTION

This project is all about a quiz which is developed using basic Java programming like if, else
statements. This is the program of quiz game which test our IQ. First statement for greeting (Welcome).
Asking for interest if player text "yes" i.e., only start. If player text "no" i.e., quit & end the game.
Initial score is equal to zero before starting answering the given questions. Display questions from 1 to
10. For every question this Java program automatically checks if the player entered answer is correct
or not if it corrects i.e., display correct else display in correct. If and only if player answer is correct
i.e., only score will be incremented else no change in score (no-negative percentage). After completing
all the 10 questions it displays how many questions do you attempt correctly out of 10 and also display
over-all percentage. Final statement ends with thanks greeting.

The application enables users to create multiple-choice quizzes with customizable questions and
answer options. It supports a wide range of question types, including true/false, multiple-choice, and
fill-in-the-blank. Each quiz can have a predefined number of questions and can be assigned a time limit
for completion. To enhance user engagement, the quiz application includes features like scoring and
feedback. After completing a quiz, users receive an immediate score and feedback on their
performance. The application also offers the option to review answers and see correct solutions for
each question.

Furthermore, the quiz application includes functionalities for quiz management. It allows users to
create, edit, and delete quizzes, as well as add or remove questions from existing quizzes. The
application stores quiz data in a file or database, ensuring persistent storage and easy retrieval of quiz
information.

1
CHAPTER 2

DESIGN AND IMPLEMENTATION


2.1 DESIGN

Figure 1.1 Design of System

2.2 SYSTEM SETUP


➢ The program is saved in the following process:
➢ Open the notepad in your laptop or desktop
➢ Do not forget to download the JDK from the online which is used as interpreter to
executing the code.
➢ Then start writing the code in the Notepad
➢ NOTE: Write the program very carefully try to write it without errors and do the
follow the steps of program that are required in the Java.
➢ Then save the file with .java extension.
➢ Open in CMD-prompt(jdk) the file and execute in the program then you see the
errors and work on it.

2
2.3 PROGRAM
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Project7567 extends JFrame {
private JLabel questionLabel;
private JLabel headingLabel;
private JLabel textLabel;
private JTextField answerField;
private JButton submitButton;
private int score;
private String [] [] questions = {
{"What is the name of the Java compiler?", "javac"},
{"Which keyword is used to define a method that does not return any value in Java?",
"void"},
{"Which Java keyword is used to define a subclass of a class?", "extend"},
{"Dancing Java program is known as?", "swing"},
{"What is the name of the method that gets automatically invoked when an object is
created?", "constructor"},
{"What do you call a group of Java developers?", "array"},
{"What is JVM?", "platform"},
{"What is the process of combining multiple classes into one called?",
"inheritance"},
{"Which keyword is used to handle exceptions in Java?", "try"},
{"What is the keyword used to declare a variable that won't change its value?",
"final"}
};
private int currentQuestionIndex;
public Project7567() {
super("Quiz");
headingLabel = new JLabel ("Welcome to the Quiz");
headingLabel.setFont(new Font ("Arial", Font. BOLD, 20));
questionLabel = new JLabel ();
answerField = new JTextField (20);
submitButton = new JButton("Submit");
textLabel = new JLabel ("Done by J. Yashwanth Reddy, R. SaiGanesh, Y. Mohana
Laxmi");
textLabel.setFont(new Font ("Times New Roman", Font.ITALIC, 10));
score = 0;
currentQuestionIndex = 0;
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(10, 10, 10, 10);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.CENTER;
panel.add(headingLabel, gbc);
gbc.gridy = 1;
gbc.gridwidth = 2;
panel.add(questionLabel, gbc);
3
gbc.gridy = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
panel.add(answerField, gbc);
gbc.gridy = 3;
gbc.gridwidth = 2;
panel.add(submitButton, gbc);
gbc.gridy = 4;
gbc.gridwidth = 2;
panel.add(textLabel, gbc);
add(panel);
submitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
checkAnswer();
}
});
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
setVisible(true);
showNextQuestion();
}
private void showNextQuestion() {
if (currentQuestionIndex < questions.length) {
questionLabel.setText(questions[currentQuestionIndex][0]);
answerField.setText("");
} else {
showResult();
}
}
private void checkAnswer() {
String userAnswer = answerField.getText();
if (userAnswer.equalsIgnoreCase(questions[currentQuestionIndex][1])) {
score++;
}
currentQuestionIndex++;
showNextQuestion();
}
private void showResult() {
double percentage = (score / (double) questions.length) * 100;
JOptionPane.showMessageDialog(this, "You got " + score + " questions correct\n" +
"You got " + percentage + "%");
System.exit(0);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Project7567();
}
});
}
}

4
2.4 IMPLEMENTATION

➢ This is the program of quiz game which test our IQ.


➢ First statement for greeting (Welcome).
➢ Initial score is equal to zero before starting answering the given questions.
➢ Let’s start the game.
➢ Display questions from 1 to 10. For every question this python program automatically
checks if the player entered answer is correct or not if it corrects i.e., display correct else
display in correct.
➢ If and only if player answer is correct i.e., only score will be incremented else no change
in score (no-negative percentage).
➢ After completing all the 10 questions it displays how many questions do you attempt
correctly out of 10 and also display over-all percentage.
➢ Final statement ends with thanks greeting.

2.5 LIMITATIONS
➢ The solutions to the questions in the quiz may be not actually know to the users.
➢ The programmer needs to have code the program without any syntax or logical errors.
➢ The users have no option to clear their response once they have submitted or entered the
answer to the question.
➢ The users cannot see the remaining questions without completing the recent question.
➢ The previous answers cannot be changed.

5
CHAPTER 3

RESULTS AND OUTPUTS

Figure 3.1 Result 1

Figure 3.2 Result 2

Figure 3.3 Result 3

6
Figure 3.4 Result 4

Figure 3.5 Result 5

Figure 3.6 Result 6

7
Figure 3.7 Result 7

Figure 3.8 Result 8

Figure 3.9 Result 9

8
Figure 3.10 Result 10

Figure 3.11 Final Result

9
CHAPTER 4

CONCLUSION AND FUTURE SCOPE

6.1 CONCLUSION
From this project one can understand the basic operations used in the Java programming.
Using those basic we can build a program. This is the project is basically a basic quiz which
is developed using if, else conditions and doing mathematical calculations for the average
score.

6.2 FUTURE SCOPE


Make it multiplayer - Try modifying this game so that more than one player can enjoy this
game at once. You can do this by simply adding an additional for loop which will contain
the names of the players and score of each player is stored separately. The player with the
highest score will win the game.
Use MCQ format - Not just quiz, you can also use it conduct MCQ tests. All you have to
do is modify the print function to print the multiple answers and the player will have to
guess the right answer.
Use an API - Make use of an interesting API to automatically fetch questions from the
web so you do not have to get into the hassle of creating the questions and answers on
your own.

10
REFERENCES

[1] How do you create a simple quiz in Java? (n.d.). Quora. https://www.quora.com/How-do-
you-create-a-simple-quiz-in-Java

[2] Garcia, C. (2023). Simple Quiz Application In Java With Source Code. Source Code &
Projects. https://code-projects.org/simple-quiz-application-in-java-with-source-code/

11

You might also like