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

AJP Microproject

The document is a micro project report on creating a 'Simple Calculator Using AWT Component' submitted by students for a Diploma in Information Technology. It includes project details, methodology, advantages, and a sample code for a calculator application built using Java AWT. The project aims to develop a GUI-based calculator that performs basic arithmetic operations and demonstrates the use of event handling in Java programming.
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)
4 views15 pages

AJP Microproject

The document is a micro project report on creating a 'Simple Calculator Using AWT Component' submitted by students for a Diploma in Information Technology. It includes project details, methodology, advantages, and a sample code for a calculator application built using Java AWT. The project aims to develop a GUI-based calculator that performs basic arithmetic operations and demonstrates the use of event handling in Java programming.
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/ 15

A

Micro project report On

“Simple Calculator Using AWT


Component”

SUBMITTED TO M.S.B.T.E., Mumbai

For the Award of


DIPLOMA IN INFORMATION TECHNOLOGY BY

Roll no Name of Student Enrollment no


27 Sanket Shivaji Zombade 2110740099
41 Yuveaj Balasaheb Surshetwar 2110740125
12 Vishwas Sachin Bankar 2110740081
57 Yashvardhan Pratap Vibhute 2110740430
UNDER THE GUIDANCE OF
Mrs.S.V.Saraf.
DEPARTMENT OF INFORMATION TECHNOLOGY
NBA ACCREDIATED

SVERI’s College of Engineering (Polytechnic), Pandharpur


Gopalpur Pandharpur-413304
2023-24
AFFILIATED TO

M.S.B.T.E.
Evolution sheet for Micro Project

Academic Year:- 2023-24 Name of Faculty:- Mrs.S.V.Saraf


Course:- Information Technology Course code:- IF5I
Subject:- Advanced Java Programming Subject Code:- 22517
Semester:- V Scheme:- I

Title of Project:- “Simple Calculator Using AWT Component”


COs addressed by the Micro Project:

CO 1 Develop Program using GUI Framework(AWT And Swing) .

CO3 Develop Program of Handle event in java Programming.

Comments/Suggestions about team work/leadership/inter-personal communication (if any)

Marks out of 4
Marks out of 6 Total
for
for mars
Roll No Name of students performance
performance in out
in oral/
group activity of 10
Presentation

27 Sanket Shivaji Zombade


41 Yuveaj Balasaheb Surshetwar
12 Vishwas Sachin Bankar
57 Yashvardhan Pratap Vibhute

Name and
Signature of Mrs.S.V.Saraf
faculty
SVERI’s COLLEGE OF ENGINEERING (POLYTECHNIC), PANDHARPUR.

CERTIFICATE

This is to certify that the Project report entitled


“Simple Calculator Using AWT
Component”
Submitted by

Roll no Name of Student Enrollment no


27 Sanket Shivaji Zombade 2110740099
41 Yuveaj Balasaheb Surshetwar 2110740125
12 Vishwas Sachin Bankar 2110740081
57 Yashvardhan Pratap Vibhute 2110740430
is a bonafide work carried out by above students, under the guidance of Mrs.S.V.Saraf. and it is
submitted towards the fulfillment of requirement of MSBTE, Mumbai for the award of Diploma in
Information Technology at SVERI’s COE (Polytechnic), Pandharpur during the academic year 2022-2023.

(Mrs.S.V.Saraf)
Guide
(Mr.G.S.Misal.) (Dr.N.D.MIsal.)
HOD Principal

Place: Pandharpur

Date: / /
• Acknowledgement

“Simple Calculator Using AWT Components” has been developed successfully with a
great contribution of two students in a period of two months. We like to appreciate their
guidance, encouragement and willingness since without their support the project would not have
been a success. We would like to give our heartfelt gratitude to Principal Dr. N. D. Misal, Guide
Ms.S.V.Saraf & HOD Mr.G.S.Misal who is the supervisor of our project for helping and
encouraging us in many ways to make our project a success. We would never been able to finish
our work without great support and enthusiasm from friends and support from our family. We
would like to thank the department of Information Technology, for giving us permission to initiate
this project and successfully finishit.
• Introduction

This calculator has some very simple features of add, subtract, multiply and divide.
So let’s get started to learn how to create a simple calculator in Java AWT.

Java AWT(Abstract Window Toolkit) is an API that helps in building GUI based
java applications.GUI helps in user interactions using some graphics. As a result, our
operating systems have some underlying GUI’s such as windows, frames, textfield,
labels, etc.
• Resources Used

Sr. No. Specification Remark


1 Intel Core i3/ i5, RAM 8GB As per requirement
2 Operating System – Windows 11 As per requirement
3 Application – Microsoft Word 2016 As per requirement
• Advantages

1. Speed: Calculators are much faster than doing calculations mentally or on paper,
especially for complex or lengthy calculations.
2. Accuracy: Calculators eliminate the risk of making arithmetic errors, providing more
accurate results than manual calculations.
3. Complex calculations: Calculators can handle complex mathematical operations, such as
trigonometry and logarithms, which may be difficult or time-consuming to perform
mentally or on paper.
4. Convenience: Calculators are portable and can be used anywhere, making them
convenient for on-the-go calculations.

COs addressed by the Micro Project:

CO 1 Develop Program using GUI Framework(AWT And Swing) .

CO3 Develop Program of Handle event in java Programming.


• Methodology

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 THE WINDOW
public void windowClosing(WindowEvent e) {
f.dispose();
}

public void actionPerformed(ActionEvent e){


String z,zt;

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 SUBTRACTION
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 DIVISION
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);
}

}
//MAIN METHOD where objects of MyCalc is instantaiated
public static void main(String args[]){
new MyCalc();
}
}
• OUTPUT
• CONCLUSION

A calculator program can be put to use to perform arithmetic operations like addition,
subtraction, division, multiplication, and modulo of two numbers by getting user input
and giving the output as the result of the computation

• REFERENCES:

1. https://www.google.com

2. https://www.javatpoint.com

You might also like