AJP Microproject

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

A

MICRO PROJECT REPORT


ON

Calculator in java(2021-2022)

SUBMITTED BY

Sakshi pingle Enrollment No. 1905300038


Damini Sonawane. Enrollment No. 1905300035
Bhavna Khairnar Enrollment No. 1705300033

Project Guided by

Prof.G.A.SONAWANE.

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION, Mumbai

Mahavir Polytechnic, Nashik.(0530)


DEPARTMENT OF COMPUTER ENGINEERING

2021-2022

1
MAHAVIR POLYTECHNIC, NASHIK.

DEPARTMENT OF COMPUTER ENGINEERING

CERTIFICATE
This is to certify that the Micro Project Report on "Calculator in java"is satisfactorily
completed and submitted in the partial fulfillment of the requirement for Subject
"Advance java programming "in Third Year Computer Engineering in "Semester
Fifth" Academic Year 2021-2022.

By

Sakshi pingle
Damini sonawane
Bhavna khairnar

Prof. G.A.SONAWANE PROF. A.D. SONAWANE Prof. S.V. SAGARE


(Project Guide) (H.O.D.) (Principal)

2
ACKNOWLEDGEMENT

I take this opportunity to thank all those who have contributed in successful
completion of this Micro Project work. I would like to express my sincere thanks to
my Project Guided by Prof.G.A.SONAWANE. who has encouraged me to work on
this project and guided me whenever required.
We also would like to express our gratitude to our H.O.D. Prof.A.D.SONAWANEfor
giving us opportunities to undertake this project works at Mahavir Polytechnic,
Nashik.
We are extremely grateful to our Principal Prof.S.V.SAGREfor his constant
inspiration and keen interest to make the project and presentation absolutely
flawless.
At the last but not the least we would like to thank our Teaching staff member,
Workshop staff member, Friends and family member for their timely co-operation
and help.

MS.sakshi pingle.
Enrollment No. 1905300038

MS. Damini sonawane.


Enrollment No. 1905300035

MS. Bhavana khairnar


Enrollment No. 1705300033

T.Y.C.O
Academic Year 2021-22
Fifth Semester

3
Annexure – I
PART A – Micro-Project Proposal

CALCULATOR IN JAVA

1.0 Brief Introduction


A basic calculator is able to add, subtract, multiply or divide two numbers.
This is done using a switch case.

2.0 Aim of the Micro-Project


Create a simple calculator which can perform basic arithmetic operations like
addition, subtraction, multiplication or division depending upon the user
input.

3.0 Intended Course Outcomes


1. Develop programs using GUI framework (AWT and Swing).
2. Handle events of handle events in java programming.
3. Develop programs to handle events in java programming.

4.0 Literature Review


They calculate runtime performance of different OOP and procedure ... finding in
many Institutions around world has adopted java as the language to first.
www.javapoint.com
www.tutorialspoint.com

5.0 Proposed Methodology


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.

6.0 Resources Required


S. No. Name of Specifications Qty Remarks
Resource/material
1 Hardware : computer Computer 1GB Ram 1
system
2 Operating system Windows 1
3 Software Jdk1.7 1
4 Internet connection - -

7.0 Action Plan

4
Sr. Details of activity Planned Planned Name of Responsible
No. Start date Finish date Team Members
1 Selection topic

2 Finalizing topic
.

3 Information search

4 Information search

5 Making repot

6 Submission report

5
Annexure – II

PART B – Micro-Project Report

CALCULATOR IN JAVA
1.0 Rationale
A basic calculator is able to add, subtract, multiply or divide two numbers.
This is done using a switch case.

2.0 Course Outcomes Addressed


1. Develop programs using GUI framework (AWT and Swing).
2. Handle events of handle events in java programming.
3. Develop programs to handle events in java programming.

3.0 Literature Review


They calculate runtime performance of different OOP and procedure ... finding in
many Institutions around world has adopted java as the language to first.
www.javapoint.com
www.tutorialspoint.com

4.0 Actual Methodology Followed


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.

6.0 Resources Required


S. No. Name of Specifications Qty Remarks
Resource/material
1 Hardware : computer Computer 1GB Ram 1
system
2 Operating system Windows 1
3 Software Jdk1.7 1
4 Internet connection - -

6.0 Outputs of the Micro-Project

6
7
7.0 Skill Developed / learning out of this Micro-Project
Create a simple calculator which can perform basic arithmetic operations like
addition, subtraction, multiplication or division depending upon the user
input.

8.0 Applications of this Micro-Project


1. Our project will be able to implement in future after making some
changes and modifications as we make our project at a very low level. So
the modifications that can be done in our project are:

2. To make it screen touch so no need to touch key buttons and one more
change which can we made is to add snaps of the person who use it.

8
INDEX

SR. NO. Topic PAGE NO.

1 Introduction 10

2 Requirement analysis 10
2.1 Hardware requirements
2.2 Software requirements
3 Project planning
3.1 Schedule estimation(s/w & h/w) 11
3.2 Project plan

4 Output
4.1 program code 11-21
4.2 output of the code

5 Advantages 21

6 Applications and future scope 21

7 Conclusion 21

8 References 22

9
INTRODUCTION

A calculator is a small, portable, often inexpensive electronic device that is used to


perform both basic and complex operation of arithmetic.
A basic calculator is able to add, subtract, multiply or divide two numbers. This is
done using a switch case.
In this Program we are making a simple calculator that performs addition,
subtraction, multiplication and division based on the user input. The program takes
the value of both the numbers (entered by user) and then user is asked to enter the
operation (+, -, * and /), based on the input program performs the selected
operation on the entered numbers using switch case.

RESOURCES REQUIRED

S. Name of
Specifications Qty. Remarks
No. Resource/material

Notepad, Command
1 Software 1 -
Prompt

2 RAM 1 GB 1 -

3 Hard disk 40 GB 1 -

4 Processor Pentium 1 -

5 Operating system Windows 7 1 -

10
PROJECT PLANNING

Sr. Details of activity Planned Planned Name of Responsible


No. Start date Finish date Team Members
1 Selection topic

2 Finalizing topic
Sakshi pingle
3 Information search Damini sonawane

4 Information search
Bhavna khairnar.

5 Making repot

6 Submission report

PROGRAM CODE

/*********************************************
Save this file as MyCalculator.java
to compile it use
javac MyCalculator.java
to use the calcuator do this
java MyCalculator

**********************************************/
import java.awt.*;
import java.awt.event.*;
/*********************************************/

public class MyCalculator extends Frame


{

public boolean setClear=true;


double number, memValue;
char op;

11
String digitButtonText[] = {"7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "+/-", "." };
String operatorButtonText[] = {"/", "sqrt", "*", "%", "-", "1/X", "+", "=" };
String memoryButtonText[] = {"MC", "MR", "MS", "M+" };
String specialButtonText[] = {"Backspc", "C", "CE" };

MyDigitButton digitButton[]=new MyDigitButton[digitButtonText.length];


MyOperatorButton operatorButton[]=new MyOperatorButton[operatorButtonText.l
ength];
MyMemoryButton memoryButton[]=new MyMemoryButton[memoryButtonText.len
gth];
MySpecialButton specialButton[]=new MySpecialButton[specialButtonText.length];

Label displayLabel=new Label("0",Label.RIGHT);


Label memLabel=new Label(" ",Label.RIGHT);

final int FRAME_WIDTH=325,FRAME_HEIGHT=325;


final int HEIGHT=30, WIDTH=30, H_SPACE=10,V_SPACE=10;
final int TOPX=30, TOPY=50;
///////////////////////////
MyCalculator(String frameText)//constructor
{
super(frameText);

int tempX=TOPX, y=TOPY;


displayLabel.setBounds(tempX,y,240,HEIGHT);
displayLabel.setBackground(Color.BLUE);
displayLabel.setForeground(Color.WHITE);
add(displayLabel);

memLabel.setBounds(TOPX, TOPY+HEIGHT+ V_SPACE,WIDTH, HEIGHT);


add(memLabel);

// set Co-ordinates for Memory Buttons


tempX=TOPX;
y=TOPY+2*(HEIGHT+V_SPACE);
for(int i=0; i<memoryButton.length; i++)

12
{
memoryButton[i]=new MyMemoryButton(tempX,y,WIDTH,HEIGHT,memoryButtonT
ext[i], this);
memoryButton[i].setForeground(Color.RED);
y+=HEIGHT+V_SPACE;
}

//set Co-ordinates for Special Buttons


tempX=TOPX+1*(WIDTH+H_SPACE); y=TOPY+1*(HEIGHT+V_SPACE);
for(int i=0;i<specialButton.length;i++)
{
specialButton[i]=new MySpecialButton(tempX,y,WIDTH*2,HEIGHT,specialButtonText
[i], this);
specialButton[i].setForeground(Color.RED);
tempX=tempX+2*WIDTH+H_SPACE;
}

//set Co-ordinates for Digit Buttons


int digitX=TOPX+WIDTH+H_SPACE;
int digitY=TOPY+2*(HEIGHT+V_SPACE);
tempX=digitX; y=digitY;
for(int i=0;i<digitButton.length;i++)
{
digitButton[i]=new MyDigitButton(tempX,y,WIDTH,HEIGHT,digitButtonText[i], this);
digitButton[i].setForeground(Color.BLUE);
tempX+=WIDTH+H_SPACE;
if((i+1)%3==0){tempX=digitX; y+=HEIGHT+V_SPACE;}
}

//set Co-ordinates for Operator Buttons


int opsX=digitX+2*(WIDTH+H_SPACE)+H_SPACE;
int opsY=digitY;
tempX=opsX; y=opsY;
for(int i=0;i<operatorButton.length;i++)
{
tempX+=WIDTH+H_SPACE;

13
operatorButton[i]=new MyOperatorButton(tempX,y,WIDTH,HEIGHT,operatorButton
Text[i], this);
operatorButton[i].setForeground(Color.RED);
if((i+1)%2==0){tempX=opsX; y+=HEIGHT+V_SPACE;}
}

addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent ev)
{System.exit(0);}
});

setLayout(null);
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setVisible(true);
}
//////////////////////////////////
static String getFormattedText(double temp)
{
String resText=""+temp;
if(resText.lastIndexOf(".0")>0)
resText=resText.substring(0,resText.length()-2);
return resText;
}
////////////////////////////////////////
public static void main(String []args)
{
new MyCalculator("Calculator - JavaTpoint");
}
}

/*******************************************/

class MyDigitButton extends Button implements ActionListener


{
MyCalculator cl;

14
//////////////////////////////////////////
MyDigitButton(int x,int y, int width,int height,String cap, MyCalculator clc)
{
super(cap);
setBounds(x,y,width,height);
this.cl=clc;
this.cl.add(this);
addActionListener(this);
}
////////////////////////////////////////////////
static boolean isInString(String s, char ch)
{
for(int i=0; i<s.length();i++) if(s.charAt(i)==ch) return true;
return false;
}
/////////////////////////////////////////////////
public void actionPerformed(ActionEvent ev)
{
String tempText=((MyDigitButton)ev.getSource()).getLabel();

if(tempText.equals("."))
{
if(cl.setClear)
{cl.displayLabel.setText("0.");cl.setClear=false;}
else if(!isInString(cl.displayLabel.getText(),'.'))
cl.displayLabel.setText(cl.displayLabel.getText()+".");
return;
}

int index=0;
try{
index=Integer.parseInt(tempText);
}catch(NumberFormatException e){return;}

if (index==0 && cl.displayLabel.getText().equals("0")) return;

if(cl.setClear)

15
{cl.displayLabel.setText(""+index);cl.setClear=false;}
else
cl.displayLabel.setText(cl.displayLabel.getText()+index);
}//actionPerformed
}//class defination

/********************************************/

class MyOperatorButton extends Button implements ActionListener


{
MyCalculator cl;

MyOperatorButton(int x,int y, int width,int height,String cap, MyCalculator clc)


{
super(cap);
setBounds(x,y,width,height);
this.cl=clc;
this.cl.add(this);
addActionListener(this);
}
///////////////////////
public void actionPerformed(ActionEvent ev)
{
String opText=((MyOperatorButton)ev.getSource()).getLabel();

cl.setClear=true;
double temp=Double.parseDouble(cl.displayLabel.getText());

if(opText.equals("1/x"))
{
try
{double tempd=1/(double)temp;
cl.displayLabel.setText(MyCalculator.getFormattedText(tempd));}
catch(ArithmeticException excp)
{cl.displayLabel.setText("Divide by 0.");}
return;
}

16
if(opText.equals("sqrt"))
{
try
{double tempd=Math.sqrt(temp);
cl.displayLabel.setText(MyCalculator.getFormattedText(tempd));}
catch(ArithmeticException excp)
{cl.displayLabel.setText("Divide by 0.");}
return;
}
if(!opText.equals("="))
{
cl.number=temp;
cl.op=opText.charAt(0);
return;
}
// process = button pressed
switch(cl.op)
{
case '+':
temp+=cl.number;break;
case '-':
temp=cl.number-temp;break;
case '*':
temp*=cl.number;break;
case '%':
try{temp=cl.number%temp;}
catch(ArithmeticException excp)
{cl.displayLabel.setText("Divide by 0."); return;}
break;
case '/':
try{temp=cl.number/temp;}
catch(ArithmeticException excp)
{cl.displayLabel.setText("Divide by 0."); return;}
break;
}//switch

cl.displayLabel.setText(MyCalculator.getFormattedText(temp));

17
//cl.number=temp;
}//actionPerformed
}//class

/****************************************/

class MyMemoryButton extends Button implements ActionListener


{
MyCalculator cl;

/////////////////////////////////
MyMemoryButton(int x,int y, int width,int height,String cap, MyCalculator clc)
{
super(cap);
setBounds(x,y,width,height);
this.cl=clc;
this.cl.add(this);
addActionListener(this);
}
////////////////////////////////////////////////
public void actionPerformed(ActionEvent ev)
{
char memop=((MyMemoryButton)ev.getSource()).getLabel().charAt(1);

cl.setClear=true;
double temp=Double.parseDouble(cl.displayLabel.getText());

switch(memop)
{
case 'C':
cl.memLabel.setText(" ");cl.memValue=0.0;break;
case 'R':
cl.displayLabel.setText(MyCalculator.getFormattedText(cl.memValue));break;
case 'S':
cl.memValue=0.0;
case '+':
cl.memValue+=Double.parseDouble(cl.displayLabel.getText());

18
if(cl.displayLabel.getText().equals("0") || cl.displayLabel.getText().equals("0.0") )
cl.memLabel.setText(" ");
else
cl.memLabel.setText("M");
break;
}//switch
}//actionPerformed
}//class

/*****************************************/

class MySpecialButton extends Button implements ActionListener


{
MyCalculator cl;

MySpecialButton(int x,int y, int width,int height,String cap, MyCalculator clc)


{
super(cap);
setBounds(x,y,width,height);
this.cl=clc;
this.cl.add(this);
addActionListener(this);
}
//////////////////////
static String backSpace(String s)
{
String Res="";
for(int i=0; i<s.length()-1; i++) Res+=s.charAt(i);
return Res;
}

//////////////////////////////////////////////////////////
public void actionPerformed(ActionEvent ev)
{
String opText=((MySpecialButton)ev.getSource()).getLabel();
//check for backspace button
if(opText.equals("Backspc"))

19
{
String tempText=backSpace(cl.displayLabel.getText());
if(tempText.equals(""))
cl.displayLabel.setText("0");
else
cl.displayLabel.setText(tempText);
return;
}
//check for "C" button i.e. Reset
if(opText.equals("C"))
{
cl.number=0.0; cl.op=' '; cl.memValue=0.0;
cl.memLabel.setText(" ");
}

//it must be CE button pressed


cl.displayLabel.setText("0");cl.setClear=true;
}//actionPerformed
}//class

/*********************************************
Features not implemented and few bugs

i) No coding done for "+/-" button.


ii) Menubar is not included.
iii)Not for Scientific calculation
iv)Some of the computation may lead to unexpected result
due to the representation of Floating point numbers in computer
is an approximation to the given value that can be stored
physically in memory.
***********************************************/

20
OUTPUT

ADVANTAGES

1. Calculator can solve People will be so dependant.


2. Easy to operate.
3. User friendly.

APPLICATIONS AND FUTURE SCOPE


Our project will be able to implement in future after making some changes and
modifications as we make our project at a very low level. So the modifications that
can be done in our project are:

To make it screen touch so no need to touch key buttons and one more change
which can we made is to add snaps of the person who use it.

CONCLUSION
In this Program we are making a simple calculator that performs addition,
subtraction, multiplication and division based on the user input. The program takes
the value of both the numbers (entered by user) and then user is asked to enter the
operation (+, -, * and /), based on the input program performs the selected
operation on the entered numbers using switch case.

21
REFERENCES
1.https://www.w3schools.com/java/default.asp- From this website we got the
information about Java Programming.

2. JAVA PROGRAMMING– Publications: Pankaj B. Brahmankar: From this book we


got the various Syntax, Data types and Functions.

3.https://www.wikihow.com/Compile-%26-Run-Java-Program-Using-Command-
Prompt - From this website we learn how to run java program in command prompt.

22
Annexure – III
Teacher Evaluation Sheet
Name of Student : Sakshi Kailas Pingle. Enrollment No:1905300038.
Name of Program: computer engineering. Semester: fifth semester.
Course Title : Advanced java programming
Code: 22517.

Title of the Micro-Project: calculator in java.

Course Outcomes Achieved : 1 Develop programs using GUI framework (AWT and
Swings).
2. Handle events of AWT and Swing components.
3. Develop program using database.
4. Develop program using servlets.

Evaluation as per Suggested Rubric for Assessment of Micro Project


 (Please tick in appropriate cell for each characteristic)
S. Characteristic Poor Average Good Excellent
No. to be ( Marks ( Marks 4 - 5 ) ( Marks 6 - 8 ) ( Marks 9-
assessed 1-3 ) 10 )
1 Relevance to
the course
2 Literature
Survey
/information
collection
3 Completion of
the Target as
per project
proposal
4 Analysis of
Data and
representatio
n
5 Quality of
Prototype/M
odel

6 Report
Preparation
7 Presentation

8 Any other

23
S. Characteristic Poor Average Good Excellent
No. to be ( Marks ( Marks 4 - 5 ) ( Marks 6 - 8 ) ( Marks 9-
assessed 1-3 ) 10 )
(depending
upon nature
of project:
please write
indicators by
pen)
9 Defense

MIcro-Project Evaluation Sheet

Process Assessment Product Assessment Total


Part A - Project Part B - Project individual Marks
Project Methodology Report/Working Presentation/Viva 10
Proposal (2 marks) Model (4 marks)
(2 marks) (2 marks)

Note:
Every course teacher is expected to assign marks for group evolution for each group
of students in first 3 columns as per rubrics & individual evaluation in 4TH column for
each group of students as per rubrics based on viva.

Comments/Suggestions about team work/leadership/inter-personal


communication (if any)
…………………………………………………………………………………………………………………………
………
……………………………………………………..
……………………………………………………………………………………………..
…………………………………………………………………………………………………………………

Any Other Comment:


…………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………
………………………………

Name and designation of the Faculty Member……………………………………………

Signature……………………………………………………………………………………………

24
Annexure – III
Teacher Evaluation Sheet
Name of Student : Damini Ramrao Sonawane. Enrollment No: 1905300035.
Name of Program: computer engineering. Semester: fifth semester.
Course Title : advanced java programming.
Code: 22517

Title of the Micro-Project: calculator in java.


Course Outcomes Achieved : 1. Develop programs using GUI framework (AWT and
Swings).
2. Handle events of AWT and Swing components.
3. Develop program using database.
4. Develop program using servlets.

Evaluation as per Suggested Rubric for Assessment of Micro Project


 (Please tick in appropriate cell for each characteristic)
S. Characteristic Poor Average Good Excellent
No. to be ( Marks ( Marks 4 - 5 ) ( Marks 6 - 8 ) ( Marks 9-
assessed 1-3 ) 10 )
1 Relevance to
the course
2 Literature
Survey
/information
collection
3 Completion of
the Target as
per project
proposal
4 Analysis of
Data and
representatio
n
5 Quality of
Prototype/M
odel

6 Report
Preparation
7 Presentation

8 Any other

25
S. Characteristic Poor Average Good Excellent
No. to be ( Marks ( Marks 4 - 5 ) ( Marks 6 - 8 ) ( Marks 9-
assessed 1-3 ) 10 )
(depending
upon nature
of project:
please write
indicators by
pen)
9 Defense

MIcro-Project Evaluation Sheet

Process Assessment Product Assessment Total


Part A - Project Part B - Project individual Marks
Project Methodology Report/Working Presentation/Viva 10
Proposal (2 marks) Model (4 marks)
(2 marks) (2 marks)

Note:
Every course teacher is expected to assign marks for group evolution for each group
of students in first 3 columns as per rubrics & individual evaluation in 4TH column for
each group of students as per rubrics based on viva.

Comments/Suggestions about team work/leadership/inter-personal


communication (if any)
…………………………………………………………………………………………………………………………
………
……………………………………………………..
……………………………………………………………………………………………..
…………………………………………………………………………………………………………………

Any Other Comment:


…………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………
………………………………

Name and designation of the Faculty Member……………………………………………

Signature……………………………………………………………………………………………

Annexure – III

26
Teacher Evaluation Sheet
Name of Student : Bhavna Ravindra khairnar. Enrollment No:170500033.
Name of Program: computer engineering. Semester: fifth semester.
Course Title : Advanced java programming
Code: 22517.

Title of the Micro-Project: calculator in java.

Course Outcomes Achieved : 1 Develop programs using GUI framework (AWT and
Swings).
2. Handle events of AWT and Swing components.
3. Develop program using database.
4. Develop program using servlets.

Evaluation as per Suggested Rubric for Assessment of Micro Project


 (Please tick in appropriate cell for each characteristic)
S. Characteristic Poor Average Good Excellent
No. to be ( Marks ( Marks 4 - 5 ) ( Marks 6 - 8 ) ( Marks 9-
assessed 1-3 ) 10 )
1 Relevance to
the course
2 Literature
Survey
/information
collection
3 Completion of
the Target as
per project
proposal
4 Analysis of
Data and
representatio
n
5 Quality of
Prototype/M
odel

6 Report
Preparation
7 Presentation

8 Any other
(depending

27
S. Characteristic Poor Average Good Excellent
No. to be ( Marks ( Marks 4 - 5 ) ( Marks 6 - 8 ) ( Marks 9-
assessed 1-3 ) 10 )
upon nature
of project:
please write
indicators by
pen)
9 Defense

MIcro-Project Evaluation Sheet

Process Assessment Product Assessment Total


Part A - Project Part B - Project individual Marks
Project Methodology Report/Working Presentation/Viva 10
Proposal (2 marks) Model (4 marks)
(2 marks) (2 marks)

Note:
Every course teacher is expected to assign marks for group evolution for each group
of students in first 3 columns as per rubrics & individual evaluation in 4TH column for
each group of students as per rubrics based on viva.

Comments/Suggestions about team work/leadership/inter-personal


communication (if any)
…………………………………………………………………………………………………………………………
………
……………………………………………………..
……………………………………………………………………………………………..
…………………………………………………………………………………………………………………

Any Other Comment:


…………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………
………………………………

Name and designation of the Faculty Member……………………………………………

Signature……………………………………………………………………………………………

28
29

You might also like