Java Project Cutm

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 27

Java Project - cutm

Computer Science and Enginnering (Centurion University of Technology and


Management)

Studocu is not sponsored or endorsed by any college or university


A project report submitted
for
JAVA TECHNOLOGIES
on the topic
CALCULATOR

By

Debasis Nishank(210301120050)
Susant kumar Debata(210301120054)

Under the guidance of

Dr.Nilamadhab Das

CENTURION UNIVERSITY OF TECHNOLOGY AND MANAGEMENT,


ODISHA, INDIA
2022

1
DECLARATION

The project on “CALCULATOR”, submitted by our group, for the


partial fulfillment of Bachelor of Technology, is a record of bona
fide work carried out by our group. The result embodied in this
project work has not been submitted to any university or institution
or organization for award of degree.

DATE:

PLACE: Centurion University,Jatni

2
Acknowledgement

we would like to express our special thanks of gratitude to our


teacher “Dr.Nilamadhab Das” for him guidance and support
in completing our project.

We would also like to extend our gratitude to the DEAN


“Sujata Chakrabarti” and HOD “Mamata Garnaik” for
providing us with all the faculty that was required for the
completion of the project report.

3
Certificate
This is to certify that the project report entitled
“CALCULATOR” is a Bonafide work done by Debasis
Nishank(210301120050), Susant kumar Debata(210301120054)

of B-TECH (CSE) under the guidance of Dr.Nilamadhab


Das, Centurion University of Technology and Management,
Odisha.

The project has not been submitted to any other Institution or


University.

4
Abstract
This work was centered on the Design and
implementation of a calculator for education
organization. The study traced calculator system as a
tool to completely change mathematical knowledge and
sophisticated problems solving strategies had advanced
the field of simulated engine in mathematics.
This project work also focused principally on numbers
and arithmetic operation.
The result of simple calculator system was its ability to
process number and operators and provides a useful
result.
Therefore, this project will help Easy calculating of
tedious mathematical problems, easy to retrieval of
errors and it will also be of a good assistance to any
researcher on these topics.

5
Index
➢ System Requirement
➢ Scope Of the Project
➢ Abstract
➢ Coding
➢ Screenshot
➢ Advantages & Disadvantages
➢ Conclusion
➢ Reference

System requirement
6
H/W Requirement:-
➢ Intel i3 or above
➢ Windows 10 Operating System
➢ 256 MB RAM or above
➢ Keyboard and mouse

S/W Requirement:-
➢ JVM8.0.1s
➢ Editor like
Notepad/NetBeans/Eclipse/VS Code
➢ Command Prompt

Scope of the project


7
• Calculators are used widely in any situation where
quick access to certain mathematical functions is
needed, especially those that were once looked up
in tables, they are also used in situations requiring
calculations of very large or very small numbers, as
in some aspects of Astronomy, Physics
and Chemistry.
• They are very often required for math classes from
the junior high school level through college, and
are generally either permitted or required on
many standardized tests covering math and science
subjects; as a result, many are sold into educational
markets to cover this demand, and some high-end
models include features making it easier to
translate a problem on a textbook page into
calculator input, e.g. by providing a method to
enter an entire problem in as it is written on the
page using simple formatting tools.

coding
import java.awt.*;
import java.awt.event.*;
class myCalc extends WindowAdapter
implements ActionListener {
Frame f;
Label l1;
Button b1, b2, b3, b4, b5, b6, b7, b8, b9, b0;
Button badd, bsub, bmult, bdiv, bmod, bcalc,
bclr, bpts, bneg, bback;
double xd;
double num1, num2, check;
myCalc() {
f = new Frame("MY CALCULATOR");
// INSTANTIATING COMPONENETS
l1 = new Label();
l1.setBackground(Color.LIGHT_GRAY);
l1.setBounds(50, 50, 260, 60);

b1 = new Button("1");
b1.setBounds(50, 340, 50, 50);
b2 = new Button("2");
b2.setBounds(120, 340, 50, 50);
b3 = new Button("3");
b3.setBounds(190, 340, 50, 50);
b4 = new Button("4");
b4.setBounds(50, 270, 50, 50);
b5 = new Button("5");
b5.setBounds(120, 270, 50, 50);
b6 = new Button("6");
b6.setBounds(190, 270, 50, 50);
b7 = new Button("7");
b7.setBounds(50, 200, 50, 50);
b8 = new Button("8");
b8.setBounds(120, 200, 50, 50);
b9 = new Button("9");
b9.setBounds(190, 200, 50, 50);
b0 = new Button("0");
b0.setBounds(120, 410, 50, 50);

bneg = new Button("+/-");


bneg.setBounds(50, 410, 50, 50);
bpts = new Button(".");
bpts.setBounds(190, 410, 50, 50);
bback = new Button("back");
bback.setBounds(120, 130, 50, 50);
badd = new Button("+");
badd.setBounds(260, 340, 50, 50);
bsub = new Button("-");
bsub.setBounds(260, 270, 50, 50);
bmult = new Button ("*");
bmult.setBounds(260, 200, 50, 50);
bdiv = new Button ("/");
bdiv.setBounds(260, 130, 50, 50);
bmod = new Button ("%");
bmod.setBounds(190, 130, 50, 50);
bcalc = new Button ("=");
bcalc.setBounds(245, 410, 65, 50);
bclr = new Button("CE");
bclr.setBounds(50, 130, 65, 50);

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
b0.addActionListener(this);

bpts.addActionListener(this);
bneg.addActionListener(this);
bback.addActionListener(this);

badd.addActionListener(this);
bsub.addActionListener(this);
bmult.addActionListener(this);
bdiv.addActionListener(this);
bmod.addActionListener(this);
bcalc.addActionListener(this);
bclr.addActionListener(this);
f.addWindowListener(this);
// ADDING TO FRAME
f.add(l1);
f.add(b1);
f.add(b2);
f.add(b3);
f.add(b4);
f.add(b5);
f.add(b6);
f.add(b7);
f.add(b8);
f.add(b9);
f.add(b0);

f.add(badd);
f.add(bsub);
f.add(bmod);
f.add(bmult);
f.add(bdiv);
f.add(bmod);
f.add(bcalc);
f.add(bclr);
f.add(bpts);
f.add(bneg);
f.add(bback);
f.setSize(360, 500);
f.setLayout(null);
f.setVisible(true);
}
// FOR CLOSING THW WINDOW
public void windowClosing(WindowEvent e) {
f.dispose();
}
public void actionPerformed(ActionEvent e) {
String z, zt;
// NUMBER BUTTON
if (e.getSource() == b1) {
zt = l1.getText();
z = zt + "1";
l1.setText(z);
}
if (e.getSource() == b2) {
zt = l1.getText();
z = zt + "2";
l1.setText(z);
}
if (e.getSource() == b3) {
zt = l1.getText();
z = zt + "3";
l1.setText(z);
}
if (e.getSource() == b4) {
zt = l1.getText();
z = zt + "4";
l1.setText(z);
}
if (e.getSource() == b5) {
zt = l1.getText();
z = zt + "5";
l1.setText(z);
}
if (e.getSource() == b6) {
zt = l1.getText();
z = zt + "6";
l1.setText(z);
}
if (e.getSource() == b7) {
zt = l1.getText();
z = zt + "7";
l1.setText(z);
}
if (e.getSource() == b8) {
zt = l1.getText();
z = zt + "8";
l1.setText(z);
}
if (e.getSource() == b9) {
zt = l1.getText();
z = zt + "9";
l1.setText(z);
}
if (e.getSource() == b0) {
zt = l1.getText();
z = zt + "0";
l1.setText(z);
}
if (e.getSource() == bpts) { // ADD DECIMAL
PTS
zt = l1.getText();
z = zt + ".";
l1.setText(z);
}
if (e.getSource() == bneg) { // FOR
NEGATIVE
zt = l1.getText();
z = "-" + zt;
l1.setText(z);
}
if (e.getSource() == bback) { // FOR
BACKSPACE
zt = l1.getText();
try {
z = zt.substring(0, zt.length() - 1);
} catch
(StringIndexOutOfBoundsException f) {
return;
}
l1.setText(z);
}
// AIRTHMETIC BUTTON
if (e.getSource() == badd) { // FOR
ADDITION
try {
num1 =
Double.parseDouble(l1.getText());
} catch (NumberFormatException f) {
l1.setText("Invalid Format");
return;
}
z = "";
l1.setText(z);
check = 1;
}
if (e.getSource() == bsub) { // FOR
SUBTRACTIOM
try {
num1 =
Double.parseDouble(l1.getText());
} catch (NumberFormatException f) {
l1.setText("Invalid Format");
return;
}
z = "";
l1.setText(z);
check = 2;
}
if (e.getSource() == bmult) { // FOR
MULTIPLICATION
try {
num1 =
Double.parseDouble(l1.getText());
} catch (NumberFormatException f) {
l1.setText("Invalid Format");
return;
}
z = "";
l1.setText(z);
check = 3;
}
if (e.getSource() == bdiv) { // FOR DIVISIOM
try {
num1 =
Double.parseDouble(l1.getText());
} catch (NumberFormatException f) {
l1.setText("Invalid Format");
return;
}
z = "";
l1.setText(z);
check = 4;
}
if (e.getSource() == bmod) { // FOR
MOD/REMAINDER
try {
num1 =
Double.parseDouble(l1.getText());
} catch (NumberFormatException f) {
l1.setText("Invalid Format");
return;
}
z = "";
l1.setText(z);
check = 5;
}
// RESULT BUTTON
if (e.getSource() == bcalc) {
try {
num2 =
Double.parseDouble(l1.getText());
} catch (Exception f) {
l1.setText("ENTER NUMBER FIRST ");
return;
}
if (check == 1)
xd = num1 +
num2; if (check ==
2)
xd = num1 - num2;
if (check == 3)
xd = num1 *
num2; if (check ==
4)
xd = num1 / num2;
if (check == 5)
xd = num1 % num2;
l1.setText(String.valueOf(xd));
}
// FOR CLEARING THE LABEL and Memory
if (e.getSource() == bclr) {
num1 = 0;
num2 = 0;
check = 0;
xd =
0; z =
"";
l1.setText(z);
}
}

public static void main(String xyz[]) {


new myCalc();
}
ScreenshoT

22

Downloaded by M. Rajesh (rajeshscience2004@gmail.com)


Advantages & disadvantages
Advantages:-
• Free Online Math calculator is available for fast and easy solving of
problems
• Calculators can save a whole lot of computational time
• Calculators are free and easy to workout.
• Calculators can help to enhance the technical knowledge of a student

23

Downloaded by M. Rajesh (rajeshscience2004@gmail.com)


• Computations done via calculators are more accurate to the ones
done by humans
• Pre-defined tools used to design calculator in java like swing, applet,
frame, events and layouts etc.

Disadvantages:-
• Logical thought of mind or logical learning skills keeps on reducing day
by day.
• It is a stand-alone application and hence not distributed.
• Calculators help to promote complacency in students
• Calculators encourage students to randomly try out a variety of
arithmetical operations without understanding the reasons behind their
usage.
• Calculators result in dependence.
• They give students a false sense of confidence about their math ability.

24

Downloaded by M. Rajesh (rajeshscience2004@gmail.com)


conclusion

We think this project or desktop application is helpful


for all those who really need it. We can use this
application in everywhere for small and large as well as
complex calculations.

In this project we have started our experience about a


programming and handling programming. But to a great
extern due to coordinate of the faculty members it has
been possible for me to complete this project
“CALCULATOR”.

Finally we are grateful to my respected teachers for


extending their support and valuable guidance.

25

Downloaded by M. Rajesh (rajeshscience2004@gmail.com)


REFERENCE
➢ Programming in java complete
reference Author:-Herbert Schildt
➢ A programming with java a primer
Author:-E Balagurusamy
➢ Google
➢ http://www.javatpoint.com

➢ https://dev.to/

26

Downloaded by M. Rajesh (rajeshscience2004@gmail.com)

You might also like