0% found this document useful (0 votes)
20 views

Calculator

The document describes a calculator application created using Java. The application allows users to perform basic mathematical operations like addition, subtraction, multiplication and division. It provides an easy to use interface for solving numerical equations and calculations.

Uploaded by

Sneha Gaikwad
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Calculator

The document describes a calculator application created using Java. The application allows users to perform basic mathematical operations like addition, subtraction, multiplication and division. It provides an easy to use interface for solving numerical equations and calculations.

Uploaded by

Sneha Gaikwad
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

A PROJECT ON

CALCULATOR USING AJP


Abstract :

The Calculator is an application to calculate the values of two numbers and helps to solve
numerical equations. The system would provide basic equation like add/sub/div/multiply the
numerical equations, and manage check in specifications for the systems based on the user’s input of
need. It allows the user to Calculate the numbers and helps to solve the sums and mathematical
equations. This Software allows addition, subtraction, division and multiplication. It helps to calculate
the values and also to solve the numerical sums/equations. The Implementation of this
system will provide the options of (+,-, /,*)to calculate numerical sums.

Introduction :
The purpose of this
program is to
minimize the work
of all humans,
which is a
massive challenge.
Users working on
the equation
would be
significantly
shortened by using
this Basic
Calculator.
The machine would
be able to perform
operations such as
addition,
subtraction,
multiplication,
division, finding the
square root of a
number, etc. Quick
Calculator is user-
friendly and easy to
use.
Introduction :
The purpose of this
program is to
minimize the work
of all humans,
which is a
massive challenge.
Users working on
the equation
would be
significantly
shortened by using
this Basic
Calculator.
The machine would
be able to perform
operations such as
addition,
subtraction,
multiplication,
division, finding the
square root of a
number, etc. Quick
Calculator is user-
friendly and easy to
use.
Introduction :

The purpose of this program is to minimize the work of all humans, which is a massive
challenge. Users working on the equation would be significantly shortened by using this Basic
Calculator. The machine would be able to perform operations such as addition, subtraction,
multiplication, division, finding the square root of a number, etc. Quick Calculator is user-friendly and
easy to use.

Source Code :

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class QuizGame3 extends JFrame implements ActionListener {
JLabel lblQuestion;
JRadioButton rbOpt1, rbOpt2, rbOpt3, rbOpt4;
ButtonGroup bg;
JButton btnNext;
int current = 0, score = 0;
String[][] questions = {
{"What is the superclass of all classes in Java?",
"Object", "Class", "String", "Integer"},
{"Which statement is used to define a class in Java?",
"Class", "Method", "Inheritance", "Object"},
{"What is the keyword used to create a subclass in Java?",
"Extends", "Subclass", "Inheritance", "Parent"},
{"Which keyword is used to overload a method in java?",
"Overload", "Override", "Super", "This"},
{"Which keyword is used to access the members of a class?",
"This", "Super", "Overload", "Override"},
{"What is the keyword used to refer to a member of the superclass?",
"Super", "Parent", "Child", "Class"},
{"Which keyword is used to create an interface in Java?",
"Interface", "Class", "Extends", "Implements"},
{"Which keyword is used to prevent a class from being inherited?",
"Final", "Static", "Private", "Protected"},
{"Which keyword is used to define a method that can be overridden?",
"Virtual", "Abstract", "Final", "Override"},
{"Which keyword is used to refer to the current class instance?",
"This", "Super", "Child", "Parent"}
};
public QuizGame3( ) {
super("Java Quiz Game");
lblQuestion = new JLabel();
rbOpt1 = new JRadioButton();
rbOpt2 = new JRadioButton();
rbOpt3 = new JRadioButton();
rbOpt4 = new JRadioButton();
bg = new ButtonGroup();
btnNext = new JButton("Next Question");
btnNext.addActionListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
add(lblQuestion);
add(rbOpt1);
add(rbOpt2);
add(rbOpt3);
add(rbOpt4);
add(btnNext);
bg.add(rbOpt1);
bg.add(rbOpt2);
bg.add(rbOpt3);
bg.add(rbOpt4);
setSize(400, 400);
setVisible(true);
askQuestion();
}
public void askQuestion()
{
lblQuestion.setText(questions[current][0]);
rbOpt1.setText(questions[current][1]);
rbOpt2.setText(questions[current][2]);
rbOpt3.setText(questions[current][3]);
rbOpt4.setText(questions[current][4]); }
public void actionPerformed(ActionEvent e) {
if (rbOpt1.isSelected() || rbOpt2.isSelected() || rbOpt3.isSelected()
|| rbOpt4.isSelected()) {
if (rbOpt1.isSelected()) {
if (questions[current][1].equals("Object")
|| questions[current][1].equals("Class")
|| questions[current][1].equals("Extends")
|| questions[current][1].equals("Overload")
|| questions[current][1].equals("This")
|| questions[current][1].equals("Super")
|| questions[current][1].equals("Interface")
|| questions[current][1].equals("Final")
|| questions[current][1].equals("Virtual")
|| questions[current][1].equals("Abstract")) {
score++;
}
}
if (rbOpt2.isSelected()) {
if (questions[current][2].equals("Object")
|| questions[current][2].equals("Class")
|| questions[current][2].equals("Extends")
|| questions[current][2].equals("Overload")
|| questions[current][2].equals("This")
|| questions[current][2].equals("Super")
|| questions[current][2].equals("Interface")
|| questions[current][2].equals("Final")
|| questions[current][2].equals("Virtual")
|| questions[current][2].equals("Abstract")) {
score++; } }
if (rbOpt3.isSelected()) {
if (questions[current][3].equals("Object")
|| questions[current][3].equals("Class")
|| questions[current][3].equals("Extends")
|| questions[current][3].equals("Overload")
|| questions[current][3].equals("This")
|| questions[current][3].equals("Super")
|| questions[current][3].equals("Interface")
|| questions[current][3].equals("Final")
|| questions[current][3].equals("Virtual")
|| questions[current][3].equals("Abstract")) {
score++; } }
if (rbOpt4.isSelected()) {
if (questions[current][4].equals("Object")
|| questions[current][4].equals("Class")
|| questions[current][4].equals("Extends")
|| questions[current][4].equals("Overload")
|| questions[current][4].equals("This")
|| questions[current][4].equals("Super")
|| questions[current][4].equals("Interface")
|| questions[current][4].equals("Final")
|| questions[current][4].equals("Virtual")
|| questions[current][4].equals("Abstract")) {
score++;
}
}
current++;
if (current >= questions.length) {
btnNext.setEnabled(false);
JOptionPane.showMessageDialog(this,
"Your final score is " + score);
System.exit(0);
} else {
askQuestion();
}
} else {
JOptionPane.showMessageDialog(this,
"Please select an option!");
}
}
public static void main(String[] args) {
new QuizGame3();
}
Result / Output :
Future Scope :
Reduction of paperwork.
Human initiative or Manual Labour may be significantly minimized.
Large operations that are conducted manually can be completed in a matter of seconds.

Software Requirements:
Notepad

JAVA(jdk)

Command Prompt

Conclusion :
The Calculator allows the user to Calculate the numbers and helps to solve the sums and
mathematical equations. This Software allows addition, subtraction, division and
multiplication .It helps to calculate the values and also to solve the numerical sums/equations. The
Implementation of this system will provide the options of (+,-, /,*) to calculate numerical sums.

Reference :
www.google.com
www.geeksforgeeks.com
www.github.com
www.javapoint.com

You might also like