You are on page 1of 32

SCIENTIFIC CALCULATOR

MINOR PROJECT REPORT

By

Tanishq Bhalla(RA2211056030022)
Aryan(RA2211056030031)
Vanya Sharma(RA2211056030043)

Under the guidance of

Ms. Neha

In partial fulfilment for the Course

of

21CSC206P – ADVANCED OBJECT ORIENTED & PROGRAMMING

in CSE

FACULTY OF ENGINEERING AND TECHNOLOGY

SCHOOL OF COMPUTING

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

DELHI - NCR CAMPUS

NOVEMBER 2023
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

(Under Section 3 of UGC Act, 1956)

BONAFIDE CERTIFICATE

Certified that this minor project report for the course 21CSC206P ADVANCED

OBJECT ORIENTED & PROGRAMMING entitled in "Small Business Network

Design with Secure E-commerce server" is the bonafide work of

Tanishq(RA2211056030021),Aryan(RA2211056030031) and Vanya

Sharma(RA2211056030043) who carried out the work under my supervision.

SIGNATURE

Ms. Neha
Assistant Professor
Computer Science & Engineering
SRM Institute of Science and Technology
NCR Campus
ABSTRACT

A network has to be designed for a small business organization which

has 100 users. The organization hosts an e-commerce application on a

server which is accessible to internet users using https and with a

public IP address. A network for the same was designed using Cisco

Packet Tracer version 8.0.0. The requirements were emulated and

tested for connectivity. A server was setup, which is accessible only

on port 443 with HTTPS connectivity. Internally, department routers

are interconnected for unfiltered access to the server. The company

router has NAT to translate public IP address to private device IP

addresses. Switches are used to ensure optimal number of devices can

be used with both the company network as well as the broadband

network. Pings were used to check the connectivity and the

reachability of the systems from all the network.


ACKNOWLEDGEMENT

We express our heartfelt thanks to our honorable Vice Chancellor


Dr. C. MUTHAMIZHCHELVAN, for being the beacon in all our endeavors.
We would like to express my warmth of gratitude to our Registrar
Dr. S. Ponnusamy, for his encouragement.

We would like to express my heartfelt thanks to Dean(Engineering


& Technology),Dr. R.P.Mahapatra, for imparting confidence to complete my
course project
We are highly thankful to our my Course project Faculty Ms. Neha,
Assistant Professor, CSE, for his/her assistance, timely suggestion and
guidance throughout the duration of this course project.
We extend my gratitude to our HoD Dr. Akash Punhani, Associate
Professor, CSE and my Departmental colleagues for their Support.

Finally, we thank our parents and friends near and dear ones who
directly and indirectly contributed to the successful completion of our project.
Above all, I thank the almighty for showering his blessings on me to complete
my Course project.
TABLE OF CONTENTS

1.Introduction
2.Basic function
3.Proposed system a.Description
b.System requirements
4.System Design
5.Source code
6.Testing

1. INTRODUCTION

Scientific Calculator : The calculator was written by Rolf Howarth in


early 1996. A fully featured scientific calculator with proper operator
precedence is implemented, including trig functions and logarithms,
factorials, 12 levels of parentheses, logs to base 2 (a handy function
for information entropists!), bitwise logical operators, hex, octal,
binary and ASCII display. The calculator is written in JavaScript and
you are welcome to view the JavaScript source (visible within the
HTML page) for personal educational purposes as long as you
recognize that it is copyrighted and not in the public domain. This
calculator is now available as part of Hummingbird's Enterprise
Information Portal. All enquiries regarding licensing the calculator
should be directed to Hummingbird Ltd.

BASIC FUNCTIONS
Addition The addition (sum function) is used by clicking on the "+" button or using the keyboard. The
function results in a+b.
Subtraction The subtraction (minus function) is used by clicking on the "-" button or using the
keyboard. The function results in a-b.
Multiplication The multiplication (times function) is used by clicking on the "x" button or using the
keyboard "*" key. The function results in a*b.
Division The division (divide function) is used by clicking on the "/" button or using the keyboard "/"
key. The function results in a/b. Sign The sign key (negative key) is used by clicking on the "(-)"
button. The function results in -1*x. Square The square function is used by clicking on the "x^2"
button or type "^2". The function results in x*x.
Square Root The square root function is used by clicking on the "x" button or type "sqrt()". This
function represents x^.5 where the result squared is equal to x.
Raise to the Power The raise to the power (y raised to the x function) is used by clicking on the "y^x"
button or type "^". Natural Exponential The natural exponential (e raised to the x) is used by clicking
on the "e^x" button or type "exp()". The result is e (2.71828...) raised to x.
Logarithm The logarithm (LOG) is used by clicking on the "LOG" button or type "LOG()". Natural
Logarithm The Natural logarithm (LN) is used by clicking on the "LN" button or type "LN()". Inverse
Multiplicative inverse (reciprocal function) is used by pressing the "1/x" button or typing "inv()". This
function is the same as x^-1 or dividing 1 by the number. Exponent Numbers with exponents of 10
are displayed with an "e", for example 4.5e+100 or 4.5e-100. This function represents 10^x. Numbers
are automatically displayed in the format when the number is too large or too small for the display. To
enter a number in this format use the exponent key "EEX". To do this enter the mantissa (the non
exponent part) then press "EEX" or type"e" and then enter the exponent. Factorial The Factorial
function is used by clicking the "!" button or type "!". PI PI is a mathematical constant of the ratio of a
circle's circumference to its diameter.

PROPOSED SYSTEM
The following documentation is a project the “Name of the term paper allotted”. It is a detailed
summary of all the drawbacks of the old system and how the new proposed system overcomes these
shortcomings. The new system takes into account the various factors while designing a new system. It
keeps into the account the Economical bandwidth available for the new system. The foremost thing
that is taken care of is the Need and Requirements of the User. DESCRIPTION Before developing
software we keep following things in mind that we can develop powerful and quality software
PROBLEM STATEMENT  Problem statement was to design a module:  Which is user friendly 
Which will restrict the user from accessing other user’s data.  Which will help user in viewing his
data and privileges.  Which will help the administrator to handle all the changes. FUNCTIONS TO
BE PROVIDED: The system will be user friendly and completely menu driven so that the users shall
have no problem in using all options.  The system will be efficient and fast in response.  The system
will be customized according to needs. SYSTEM REQUIRMENTS Operating system: MS Windows
XP or Windows 10 Language: C Language Processor: Pentium IV Processor RAM: 512 MB Hard
disk: 2 GB
SYSTEM DESIGN
Then we began with the design phase of the system. System design is a solution, a “HOW TO”
approach to the creation of a new system. It translates system requirements into ways by which they
can be made operational. It is a translational from a user oriented document to a document oriented
programmers. For that, it provides the understanding and procedural details necessary for the
implementation. Here we use Flowchart to supplement the working of the new system. The system
thus made should be reliable, durable and above all should have least possible maintenance costs. It
should overcome all the drawbacks of the Old existing system and most important of all meet the user
requirements.

CODE
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ScientificCalculator;

import static java.lang.Math.pow;


import static java.lang.Math.sqrt;
import java.text.DecimalFormat;
import javax.swing.JOptionPane;

public class CalculatorUI extends javax.swing.JFrame {

private int n;
private int r;

/**
* Creates new form CalculatorUI
*/
public CalculatorUI() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the
form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jLabel1 = new javax.swing.JLabel();


jScrollPane1 = new javax.swing.JScrollPane();
outputBox = new javax.swing.JTextArea();
addButton = new javax.swing.JButton();
firstInput = new javax.swing.JTextField();
secondInput = new javax.swing.JTextField();
subButton = new javax.swing.JButton();
mulButton = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
clearButton = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
ncrButton = new javax.swing.JButton();
modButton = new javax.swing.JButton();
sinButton = new javax.swing.JButton();
cosButton = new javax.swing.JButton();
tanButton = new javax.swing.JButton();
cotButton = new javax.swing.JButton();
cosecButton = new javax.swing.JButton();
secButton = new javax.swing.JButton();
nprButton = new javax.swing.JButton();
factorialButton = new javax.swing.JButton();
xp3Button = new javax.swing.JButton();
xp2Button = new javax.swing.JButton();
xpyButton = new javax.swing.JButton();
xp1invButton = new javax.swing.JButton();
rootButton = new javax.swing.JButton();
epxButton = new javax.swing.JButton();
lnButton = new javax.swing.JButton();
eButton = new javax.swing.JButton();
logButton = new javax.swing.JButton();
absButton = new javax.swing.JButton();
exitButton = new javax.swing.JButton();
pieButton = new javax.swing.JButton();
twopxButton = new javax.swing.JButton();
tenpxButton = new javax.swing.JButton();
npieButton = new javax.swing.JButton();
Name = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Scientific Calculator");
setBackground(new java.awt.Color(0, 0, 0));
setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
setPreferredSize(new java.awt.Dimension(440, 455));

outputBox.setEditable(false);
outputBox.setColumns(20);
outputBox.setFont(new java.awt.Font("Monospaced", 1, 18)); // NOI18N
outputBox.setForeground(new java.awt.Color(102, 102, 102));
outputBox.setRows(1);
outputBox.setAutoscrolls(false);
outputBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0,
0, 0));
outputBox.setCaretColor(new java.awt.Color(255, 255, 255));
jScrollPane1.setViewportView(outputBox);

addButton.setBackground(new java.awt.Color(102, 102, 102));


addButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
addButton.setForeground(new java.awt.Color(255, 255, 255));
addButton.setText("+");
addButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addButtonActionPerformed(evt);
}
});

firstInput.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N


firstInput.setForeground(new java.awt.Color(153, 153, 153));
firstInput.setBorder(javax.swing.BorderFactory.createEtchedBorder());
firstInput.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
firstInputActionPerformed(evt);
}
});

secondInput.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N


secondInput.setForeground(new java.awt.Color(153, 153, 153));
secondInput.setBorder(javax.swing.BorderFactory.createEtchedBorder());
secondInput.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
secondInputActionPerformed(evt);
}
});

subButton.setBackground(new java.awt.Color(102, 102, 102));


subButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
subButton.setForeground(new java.awt.Color(255, 255, 255));
subButton.setText("-");
subButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
subButtonActionPerformed(evt);
}
});

mulButton.setBackground(new java.awt.Color(102, 102, 102));


mulButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
mulButton.setForeground(new java.awt.Color(255, 255, 255));
mulButton.setText("*");
mulButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mulButtonActionPerformed(evt);
}
});

jButton9.setBackground(new java.awt.Color(102, 102, 102));


jButton9.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
jButton9.setForeground(new java.awt.Color(255, 255, 255));
jButton9.setText("/");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});

clearButton.setBackground(new java.awt.Color(255, 204, 204));


clearButton.setFont(new java.awt.Font("Roboto Light", 0, 14)); //
NOI18N
clearButton.setText("Clear");
clearButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
clearButtonActionPerformed(evt);
}
});

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel2.setForeground(new java.awt.Color(153, 153, 153));
jLabel2.setText("1st");

jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel3.setForeground(new java.awt.Color(153, 153, 153));
jLabel3.setText("2nd");

ncrButton.setBackground(new java.awt.Color(102, 102, 102));


ncrButton.setFont(new java.awt.Font("Roboto Light", 0, 16)); // NOI18N
ncrButton.setForeground(new java.awt.Color(255, 255, 255));
ncrButton.setText("nCr");
ncrButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ncrButtonActionPerformed(evt);
}
});

modButton.setBackground(new java.awt.Color(102, 102, 102));


modButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
modButton.setForeground(new java.awt.Color(255, 255, 255));
modButton.setText("%");
modButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modButtonActionPerformed(evt);
}
});

sinButton.setBackground(new java.awt.Color(102, 102, 102));


sinButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
sinButton.setForeground(new java.awt.Color(255, 255, 255));
sinButton.setText("sin");
sinButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sinButtonActionPerformed(evt);
}
});

cosButton.setBackground(new java.awt.Color(102, 102, 102));


cosButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
cosButton.setForeground(new java.awt.Color(255, 255, 255));
cosButton.setText("cos");
cosButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cosButtonActionPerformed(evt);
}
});

tanButton.setBackground(new java.awt.Color(102, 102, 102));


tanButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
tanButton.setForeground(new java.awt.Color(255, 255, 255));
tanButton.setText("tan");
tanButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tanButtonActionPerformed(evt);
}
});

cotButton.setBackground(new java.awt.Color(102, 102, 102));


cotButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
cotButton.setForeground(new java.awt.Color(255, 255, 255));
cotButton.setText("cot");
cotButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cotButtonActionPerformed(evt);
}
});

cosecButton.setBackground(new java.awt.Color(102, 102, 102));


cosecButton.setFont(new java.awt.Font("Roboto Light", 0, 16)); //
NOI18N
cosecButton.setForeground(new java.awt.Color(255, 255, 255));
cosecButton.setText("cosec");
cosecButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cosecButtonActionPerformed(evt);
}
});

secButton.setBackground(new java.awt.Color(102, 102, 102));


secButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
secButton.setForeground(new java.awt.Color(255, 255, 255));
secButton.setText("sec");
secButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
secButtonActionPerformed(evt);
}
});

nprButton.setBackground(new java.awt.Color(102, 102, 102));


nprButton.setFont(new java.awt.Font("Roboto Light", 0, 16)); // NOI18N
nprButton.setForeground(new java.awt.Color(255, 255, 255));
nprButton.setText("nPr");
nprButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nprButtonActionPerformed(evt);
}
});

factorialButton.setBackground(new java.awt.Color(102, 102, 102));


factorialButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); //
NOI18N
factorialButton.setForeground(new java.awt.Color(255, 255, 255));
factorialButton.setText("n!");
factorialButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
factorialButtonActionPerformed(evt);
}
});
xp3Button.setBackground(new java.awt.Color(102, 102, 102));
xp3Button.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
xp3Button.setForeground(new java.awt.Color(255, 255, 255));
xp3Button.setText("x^3");
xp3Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
xp3ButtonActionPerformed(evt);
}
});

xp2Button.setBackground(new java.awt.Color(102, 102, 102));


xp2Button.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
xp2Button.setForeground(new java.awt.Color(255, 255, 255));
xp2Button.setText("x^2");
xp2Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
xp2ButtonActionPerformed(evt);
}
});

xpyButton.setBackground(new java.awt.Color(102, 102, 102));


xpyButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
xpyButton.setForeground(new java.awt.Color(255, 255, 255));
xpyButton.setText("x^y");
xpyButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
xpyButtonActionPerformed(evt);
}
});

xp1invButton.setBackground(new java.awt.Color(102, 102, 102));


xp1invButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); //
NOI18N
xp1invButton.setForeground(new java.awt.Color(255, 255, 255));
xp1invButton.setText("x^-1");
xp1invButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
xp1invButtonActionPerformed(evt);
}
});

rootButton.setBackground(new java.awt.Color(102, 102, 102));


rootButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); //
NOI18N
rootButton.setForeground(new java.awt.Color(255, 255, 255));
rootButton.setText("√");
rootButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rootButtonActionPerformed(evt);
}
});

epxButton.setBackground(new java.awt.Color(102, 102, 102));


epxButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
epxButton.setForeground(new java.awt.Color(255, 255, 255));
epxButton.setText("e^x");
epxButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
epxButtonActionPerformed(evt);
}
});
lnButton.setBackground(new java.awt.Color(102, 102, 102));
lnButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
lnButton.setForeground(new java.awt.Color(255, 255, 255));
lnButton.setText("ln");
lnButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
lnButtonActionPerformed(evt);
}
});

eButton.setBackground(new java.awt.Color(102, 102, 102));


eButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
eButton.setForeground(new java.awt.Color(255, 255, 255));
eButton.setText("e");
eButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
eButtonActionPerformed(evt);
}
});

logButton.setBackground(new java.awt.Color(102, 102, 102));


logButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
logButton.setForeground(new java.awt.Color(255, 255, 255));
logButton.setText("log");
logButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
logButtonActionPerformed(evt);
}
});

absButton.setBackground(new java.awt.Color(102, 102, 102));


absButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
absButton.setForeground(new java.awt.Color(255, 255, 255));
absButton.setText("|x|");
absButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
absButtonActionPerformed(evt);
}
});

exitButton.setBackground(new java.awt.Color(102, 102, 102));


exitButton.setFont(new java.awt.Font("Roboto Light", 0, 14)); //
NOI18N
exitButton.setForeground(new java.awt.Color(255, 255, 255));
exitButton.setText("Exit");
exitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitButtonActionPerformed(evt);
}
});

pieButton.setBackground(new java.awt.Color(102, 102, 102));


pieButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); // NOI18N
pieButton.setForeground(new java.awt.Color(255, 255, 255));
pieButton.setText("π");
pieButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pieButtonActionPerformed(evt);
}
});

twopxButton.setBackground(new java.awt.Color(102, 102, 102));


twopxButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); //
NOI18N
twopxButton.setForeground(new java.awt.Color(255, 255, 255));
twopxButton.setText("2^x");
twopxButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
twopxButtonActionPerformed(evt);
}
});

tenpxButton.setBackground(new java.awt.Color(102, 102, 102));


tenpxButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); //
NOI18N
tenpxButton.setForeground(new java.awt.Color(255, 255, 255));
tenpxButton.setText("10^x");
tenpxButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tenpxButtonActionPerformed(evt);
}
});

npieButton.setBackground(new java.awt.Color(102, 102, 102));


npieButton.setFont(new java.awt.Font("Roboto Light", 0, 18)); //
NOI18N
npieButton.setForeground(new java.awt.Color(255, 255, 255));
npieButton.setText("nπ");
npieButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
npieButtonActionPerformed(evt);
}
});

Name.setBackground(new java.awt.Color(204, 204, 204));


Name.setFont(new java.awt.Font("Bahnschrift", 0, 20)); // NOI18N
Name.setForeground(new java.awt.Color(153, 153, 153));
Name.setText("Scientific Calculator");

javax.swing.GroupLayout layout = new


javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup
()
.addGap(22, 22, 22)
.addGroup(layout.createParalle
lGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel2)
)
.addPreferredGap(javax.swing.L
ayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParalle
lGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(secondIn
put, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
.addComponent(firstInp
ut))
.addGroup(layout.createParalle
lGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.creat
eSequentialGroup()
.addGap(5, 5,
5)
.addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.creat
eSequentialGroup()
.addGap(27,
27, 27)
.addComponent(
Name))))
.addGroup(layout.createSequentialGroup
()
.addGap(10, 10, 10)
.addGroup(layout.createParalle
lGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.creat
eSequentialGroup()
.addComponent(
addButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
subButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
mulButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
clearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.creat
eSequentialGroup()
.addComponent(
modButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
sinButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
cosButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
tanButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
ncrButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.creat
eSequentialGroup()
.addComponent(
factorialButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
cosecButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
secButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
cotButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
nprButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.creat
eSequentialGroup()
.addComponent(
rootButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
xp2Button, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
xp3Button, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
xpyButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
xp1invButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.creat
eSequentialGroup()
.addComponent(
eButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
epxButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
logButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
lnButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
absButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.
GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(
pieButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
npieButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
twopxButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6,
6)
.addComponent(
tenpxButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredG
ap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(javax.swing.GroupLayout.DEFAU
LT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup
()
.addGroup(layout.createParalle
lGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(firstInp
ut, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Name))
.addGap(6, 6, 6)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup
()
.addGap(35, 35, 35)
.addGroup(layout.createParalle
lGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(secondIn
put, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
)))
.addGap(25, 25, 25)
.addGroup(layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addComponent(addButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(subButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(mulButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton9,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup
()
.addGap(1, 1, 1)
.addComponent(clearButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addComponent(modButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sinButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cosButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tanButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup
()
.addGap(1, 1, 1)
.addComponent(ncrButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addComponent(factorialButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(secButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cotButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup
()
.addGap(1, 1, 1)
.addGroup(layout.createParalle
lGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cosecBut
ton, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(nprButto
n, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.Compo
nentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addComponent(rootButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(xp2Button,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(xp3Button,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(xpyButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(xp1invButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addComponent(eButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(epxButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(logButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lnButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(absButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addComponent(pieButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(npieButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(twopxButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(j
avax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tenpxButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(exitButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAU
LT_SIZE, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void secButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_secButtonActionPerformed
double degrees = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
degrees = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = 1.0 / Math.cos(Math.toRadians(degrees));
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_secButtonActionPerformed

private void eButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_eButtonActionPerformed
double exp = 2.7182818284590452;
DecimalFormat df = new DecimalFormat("#.########");
try{
firstInput.setText(null);
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = exp;
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_eButtonActionPerformed

private void addButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_addButtonActionPerformed
double num1 = 0, num2 = 0;
try{
num1 = Double.parseDouble(firstInput.getText());
num2 = Double.parseDouble(secondInput.getText());
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = num1 + num2;
outputBox.setText(" " + result);
}//GEN-LAST:event_addButtonActionPerformed

private void subButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_subButtonActionPerformed
double num1 = 0, num2 = 0;
try{
num1 = Double.parseDouble(firstInput.getText());
num2 = Double.parseDouble(secondInput.getText());
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = num1 - num2;
outputBox.setText(" " + result);
}//GEN-LAST:event_subButtonActionPerformed

private void secondInputActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_secondInputActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_secondInputActionPerformed

private void firstInputActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_firstInputActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_firstInputActionPerformed

private void mulButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_mulButtonActionPerformed
double num1 = 0, num2 = 0;
try{
num1 = Double.parseDouble(firstInput.getText());
num2 = Double.parseDouble(secondInput.getText());
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = num1 * num2;
outputBox.setText(" " + result);
}//GEN-LAST:event_mulButtonActionPerformed

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_jButton9ActionPerformed
int num1 = 0, num2 = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
num1 = Integer.parseInt(firstInput.getText());
num2 = Integer.parseInt(secondInput.getText());
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = (double) num1 / (double) num2;
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_jButton9ActionPerformed
private void modButtonActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_modButtonActionPerformed
int num1 = 0, num2 = 0;
try{
num1 = Integer.parseInt(firstInput.getText());
num2 = Integer.parseInt(secondInput.getText());
if(num1<num2){
Exception x = null;
throw(x);
}
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
catch(Exception x){
JOptionPane.showMessageDialog(this, "Not possible to find modulus.
Divisor is larger than dividend.", "Error Message",
JOptionPane.ERROR_MESSAGE);
}
int result = num1 % num2;
outputBox.setText(" " + result);
}//GEN-LAST:event_modButtonActionPerformed

private void clearButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_clearButtonActionPerformed
firstInput.setText(null);
secondInput.setText(null);
outputBox.setText(null);
}//GEN-LAST:event_clearButtonActionPerformed

private void exitButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_exitButtonActionPerformed
setVisible(false);
}//GEN-LAST:event_exitButtonActionPerformed

private void sinButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_sinButtonActionPerformed
double degrees = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
degrees = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.sin(Math.toRadians(degrees));
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_sinButtonActionPerformed

private void cosButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_cosButtonActionPerformed
double degrees = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
degrees = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.cos(Math.toRadians(degrees));
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_cosButtonActionPerformed

private void tanButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_tanButtonActionPerformed
double degrees = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
degrees = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.tan(Math.toRadians(degrees));
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_tanButtonActionPerformed

private void cosecButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_cosecButtonActionPerformed
double degrees = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
degrees = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = 1.0 / Math.sin(Math.toRadians(degrees));
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_cosecButtonActionPerformed

private void cotButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_cotButtonActionPerformed
double degrees = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
degrees = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = 1.0 / Math.tan(Math.toRadians(degrees));
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_cotButtonActionPerformed

private void rootButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_rootButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = sqrt(number);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_rootButtonActionPerformed

private void xp2ButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_xp2ButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = pow(number,2);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_xp2ButtonActionPerformed

private void xp3ButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_xp3ButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = pow(number,3);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_xp3ButtonActionPerformed

private void xpyButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_xpyButtonActionPerformed
double num1 = 0, num2=0;
DecimalFormat df = new DecimalFormat("#.########");
try{
num1 = Double.parseDouble(firstInput.getText());
num2 = Double.parseDouble(secondInput.getText());
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = pow(num1,num2);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_xpyButtonActionPerformed

private void xp1invButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_xp1invButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.pow(number,-1);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_xp1invButtonActionPerformed

private void pieButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_pieButtonActionPerformed
double pie = 3.141592653589793;
DecimalFormat df = new DecimalFormat("#.########");
try{
firstInput.setText(null);
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
outputBox.setText(" " + df.format(pie));
}//GEN-LAST:event_pieButtonActionPerformed

private void npieButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_npieButtonActionPerformed
double number = 0, pie = 3.141592653589793;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = number * pie;
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_npieButtonActionPerformed

private void epxButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_epxButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.exp(number);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_epxButtonActionPerformed

private void twopxButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_twopxButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.pow(2,number);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_twopxButtonActionPerformed

private void tenpxButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_tenpxButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.pow(10,number);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_tenpxButtonActionPerformed

private void logButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_logButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.log10(number);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_logButtonActionPerformed

private void lnButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_lnButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.log(number);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_lnButtonActionPerformed

private void absButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_absButtonActionPerformed
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
double result = Math.abs(number);
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_absButtonActionPerformed

private void factorialButtonActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_factorialButtonActionPerformed
int fact=1;
double number = 0;
DecimalFormat df = new DecimalFormat("#.########");
try{
number = Double.parseDouble(firstInput.getText());
secondInput.setText(null);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
for(int i=1;i<=number;i++){
fact=fact*i;
}
double result = fact;
outputBox.setText(" " + df.format(result));
}//GEN-LAST:event_factorialButtonActionPerformed

private void ncrButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_ncrButtonActionPerformed
long n = 1, r = 1;
try{
n = Integer.parseInt(firstInput.getText());
r = Integer.parseInt(secondInput.getText());
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
long x1 = 1, x2 = 1, y = 1, z = n - r;
for (int i = 1; i <= n; i++){
x1 = x1 * i;
}
for (int i = 1; i <= r; i++){
x2 = x2 * i;
}
for (int i = 1; i <= z; i++){
y = y * i;
}
long result = x1 / (x2 * y);
outputBox.setText(" " + result);
}//GEN-LAST:event_ncrButtonActionPerformed

private void nprButtonActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_nprButtonActionPerformed
long n = 1, r = 1;
try{
n = Integer.parseInt(firstInput.getText());
r = Integer.parseInt(secondInput.getText());
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "Invalid input! Put numerical
value only.", "Error Message", JOptionPane.ERROR_MESSAGE);
}
long x = 1, y = 1, z = n - r;
for (int i = 1; i <= n; i++){
x = x * i;
}
for (int i = 1; i <= z; i++){
y = y * i;
}
long result = x / y;
outputBox.setText(" " + result);
}//GEN-LAST:event_nprButtonActionPerformed

TESTING

You might also like