[go: up one dir, main page]

0% found this document useful (0 votes)
14 views15 pages

JPR (46,54,56,63)

The document is a project report for an MCQ Quiz Generator developed using Java Swing, submitted by four students under the guidance of Dr. R. S. Patil. It outlines the project's aim to create a user-friendly quiz application that dynamically loads questions, processes answers, and displays scores, while also addressing course outcomes related to programming concepts and GUI design. The report includes acknowledgments, an introduction to the project's structure and benefits, a conclusion on its educational effectiveness, and the complete program code.

Uploaded by

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

JPR (46,54,56,63)

The document is a project report for an MCQ Quiz Generator developed using Java Swing, submitted by four students under the guidance of Dr. R. S. Patil. It outlines the project's aim to create a user-friendly quiz application that dynamically loads questions, processes answers, and displays scores, while also addressing course outcomes related to programming concepts and GUI design. The report includes acknowledgments, an introduction to the project's structure and benefits, a conclusion on its educational effectiveness, and the complete program code.

Uploaded by

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

A

PROJECT REPORT ON
“MCQ QUIZ GENERATOR”
Subject-Java Programming(314317)
SUBMITTED BY
1.Devgire Kasturi [46]
2.Gaikwad Tushar [54]
3.Gawali Radhika [56]
4.Hiwale Chetan [61]
Under the Guidance of
Dr. R. S. Patil

DEPARTMENT OF COMPUTER TECHNOLOGY


Sanjivani Rural Education Society’s
SANJIVANI K.B.P POLYTECHNIC
KOPARGAON-423601,DIST-AHILYANAGAR
(2024-2025)
Sanjivani Rural Education Society’s
SANJIVANI K.B.P POLYTECHNIC
DEPARTMENT OF COMPUTER TECHNOLOGY

CERTIFICATE
This is to certify that the Project Report entitled
“MCQ QUIZ GENERATOR”
SUBMITTED BY
1.Devgire Kasturi [46]
2.Gaikwad Tushar [54]
3.Gawali Radhika [56]
4.Hiwale Chetan [61]
Under our supervision and guidance for partial fulfilment of the requirement for
Diploma in Computer Technology affiliated to
Maharashtra State Board of Technical Education,Mumbai for academic year
2024-2025

Dr.R. S. Patil Dr.G. N. Jorvekar Prof.A. R.Mirikar


PROJECT GUIDE HOD PRINCIPAL
ACKNOWLEDGEMENT

The successful completion of this text-based adventure game


project would not have been possible without the generous support and
guidance of several individuals. First and foremost, we would like to express
our deepest appreciation to our dedicated teacher, Mr. S.B. Jadhav.

We also extend our sincere gratitude to Dr. G. N. Jorvekar, the esteemed Head
of the Computer Department. His unwavering support and the provision of his
expert guidance played a crucial role in navigating the technical aspects of this
project. His belief in our abilities and his motivation spurred us to overcome
challenges and strive for the best possible outcome.

Furthermore, we are immensely thankful to the respected Principal, Prof. A. R.


Mirikar, for his commitment to providing students with the necessary
infrastructure and resources.

Finally, we wish to acknowledge the collaborative spirit and unwavering


support of our friends and fellow team members.

1.Devgire Kasturi [46]


2.Gaikwad Tushar [54]
3.Gawali Radhika [56]
4.Hiwale Chetan [61]
INTRODUCTION

Rationalize:
The Java Swing-based quiz app is well-structured and functional. It dynamically
loads questions, processes answers, and displays the final score.

Aim:

To create a simple multiple-choice quiz application using Java Swing that


allows users to answer a series of predefined questions, calculates their score
based on correct answers, and displays the result at the end.

Benefits:

1. Introduction to Swing – Demonstrates how to build GUI applications using


Java Swing.

2. Event handling – Teaches how to use ActionListener for button actions.

3. Use of arrays and loops – Helps understand how to manage and iterate over
structured data.

4. Logical flow control – Covers decision-making using if, for, and switch-like
logic.

Course Outcomes Addressed:

1. CO1: Apply fundamental programming concepts to solve real-world


problems Demonstrates use of arrays, loops, conditionals, and object-oriented
programming (OOP) to build a functioning quiz app.
2. CO2: Design and implement interactive user interfaces Uses Java Swing
components like JFrame, JLabel, JRadioButton, ButtonGroup, and JButton to
create a GUI-based application.

3. CO3: Implement event-driven programming techniquesHandles user actions


using the ActionListener interface and responds to button clicks effectively.

Literature Review:

The development of educational software has seen significant growth with the
advancement of programming languages and user interface tools. Among these,
Java remains a popular choice for building interactive desktop applications due
to its platform independence and rich set of GUI libraries such as Java Swing.
CONCLUSION

The Java Quiz Application successfully demonstrates the application of


core Java programming concepts such as arrays, object-oriented design, event-
driven programming, and graphical user interface development using Swing.
Through a simple and interactive multiple-choice quiz format, the project
provides a user-friendly platform for testing and enhancing Java knowledge.

This project not only reinforces theoretical learning but also improves practical
skills in building standalone applications. The modular structure makes it easy
to extend with more questions or additional features like timed quizzes, score
saving, or difficulty levels. Overall, the Quiz App is an effective educational
tool and a strong foundation for more advanced application develop.

REFERENCE

● GeeksforGeeks-Java Random Class –


https://www.geeksforgeeks.org/java-util-random-nextint-java/
● W3Schools-Java Tutorial – https://www.w3schools.com/java/

PROGRAM CODE
import java.awt.*;
import java.awt.event.*;
import javax.swing.*; // Import the javax.swing package for Swing
components

public class QuizApp extends JFrame implements ActionListener {


// Array to store the quiz questions and answers.
// Each inner array represents one question and contains:
// {Question text, Option 1, Option 2, Option 3, Option 4, Correct
Answer}
String[][] questions = {
{"What is JVM?", "Java Very Machine", "Java Virtual Machine", "Just
Virtual Machine", "Java Verified Method", "Java Virtual Machine"},
{"Which keyword is used to inherit a class in Java?", "this", "super",
"extends", "implements", "extends"},
{"Which method is the entry point of a Java program?", "start()",
"main()", "run()", "init()", "main()"},
{"What is the size of int in Java?", "2 bytes", "4 bytes", "8 bytes",
"Depends on OS", "4 bytes"},
{"Which company developed Java?", "Apple", "Microsoft", "Sun
Microsystems", "Oracle", "Sun Microsystems"}
};

// Keeps track of the current question being displayed. Starts at 0.


int currentQuestion = 0;
// Stores the user's score during the quiz. Starts at 0.
int score = 0;
// JLabel to display the current question.
JLabel questionLabel;
// Array of JRadioButtons to display the multiple-choice options.
JRadioButton[] options = new JRadioButton[4];
// ButtonGroup to ensure only one option can be selected at a time.
ButtonGroup group;
// JButton to allow the user to submit their answer.
JButton submitButton;

// Constructor for the QuizApp class. This is called when a new QuizApp
object is created.
public QuizApp() {
// Set the title of the quiz window.
setTitle("Java Quiz");
// Set the initial size of the quiz window (width x height in pixels).
setSize(1000, 800);
// Set the layout manager for the window to a GridLayout with 6 rows
and 1 column.
// This will arrange the components in a grid-like fashion.
setLayout(new GridLayout(6, 1));
// Set the default close operation for the window. When the user clicks
the close button, the application will exit.
setDefaultCloseOperation(EXIT_ON_CLOSE);

// Create a new JLabel to display the question text.


questionLabel = new JLabel();
// Add the questionLabel to the quiz window so it becomes visible.
add(questionLabel);

// Create a new ButtonGroup to manage the radio buttons.


group = new ButtonGroup();
// Loop through the options array to create each radio button.
for (int i = 0; i < 4; i++) {
// Create a new JRadioButton.
options[i] = new JRadioButton();
// Add the current radio button to the ButtonGroup so that only one
can be selected.
group.add(options[i]);
// Add the current radio button to the quiz window so it becomes
visible.
add(options[i]);
}

// Create a new JButton with the text "Submit".


submitButton = new JButton("Submit");
// Add an ActionListener to the submitButton. This means that when the
button is clicked, the actionPerformed method of this class will be called.
submitButton.addActionListener(this);
// Add the submitButton to the quiz window.
add(submitButton);

// Load the first question into the quiz window.


loadQuestion();
// Make the quiz window visible to the user.
setVisible(true);
}

// Method to load the current question and its options into the GUI.
public void loadQuestion() {
// Check if there are more questions to display.
if (currentQuestion < questions.length) {
// Set the text of the questionLabel to display the current question
number and the question text.
questionLabel.setText("Q" + (currentQuestion + 1) + ": " +
questions[currentQuestion][0]);
// Loop through the options array to set the text for each radio button.
for (int i = 0; i < 4; i++) {
// Set the text of the current radio button to the corresponding
option from the questions array.
options[i].setText(questions[currentQuestion][i + 1]);
// Deselect all radio buttons before loading a new question.
options[i].setSelected(false);
}
} else {
// If all questions have been answered, show the final result.
showResult();
}
}
// This method is called when an action event occurs (in this case, when
the submit button is clicked).
public void actionPerformed(ActionEvent e) {
// Variable to store the text of the selected radio button.
String selected = null;
// Loop through the options array to find which radio button is selected.
for (JRadioButton option : options) {
// If the current radio button is selected, store its text in the 'selected'
variable and break out of the loop.
if (option.isSelected()) {
selected = option.getText();
break;
}
}

// Check if an option was selected.


if (selected != null) {
// Check if the selected option is equal to the correct answer for the
current question.
if (selected.equals(questions[currentQuestion][5])) {
// If the answer is correct, increment the score.
score++;
}
}

// Move to the next question.


currentQuestion++;
// Load the next question into the GUI.
loadQuestion();
}

// Method to display the final quiz result to the user.


public void showResult() {
// Show a message dialog with the user's final score.
JOptionPane.showMessageDialog(this, "Your score: " + score + "/" +
questions.length);
// Exit the application after showing the result.
System.exit(0);
}

// The main method is the entry point of the Java application.


public static void main(String[] args) {
// Create a new instance of the QuizApp class, which will start the quiz.
new QuizApp();
}
}
OUTPUT

You might also like