Final Ajp Project

You might also like

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

Part A Plan

To create a calculator using a java program

1. Brief Description :

In this project we have created a calculator using a java program. This project helps
students to learn about different java functions .This project students will learn how to create a
calculator using a java program. A calculator is used to perform different functions like addition,
substraction, multiplication, substraction, etc. .Each and every calculator has a IC in it in which
program is bursted.

2. Aim of the Micro project :

a) To give detailed information of how to create a calculator using java program.


b) To learn and teach about the different uses of the calculator in daily life
c) To describe about the functions and syntax used in java.
d) To give information about java language

3. Course outcome addressed :

a) Create a calculator app using java eclipse


b) Use a calculator app to perform deffirent operation likes addition , division , substraction ,
multiplication and more.

4. Proposed Methodology :

1
1. Focused on selection of appropriate topic for micro-project.
2. Select the topic i.e. Calculator using Java program.
3. Brief study as well as a survey on our topic .
4. Gather all information based on the topic of micro project.
5. Analysis and study of our topic in detail.
6. Following all the above methodologies we successfully completed with our
microproject.

5. Action plan :
Name of
Sr. Planned Planned Responsible
Details of Activity
No. start Date Finish Date Team
Members
Gathering The Raw
25.08.2020 01.09.2020
1. Information Related
3:00 to 5:00 3:00 to 5:00
To Project
03.09.2020 05.09.2020
2. Analysis
3:00 to 5:00 3:00 to 5:00 Fere Rahul
14.09.2020 21.09.2020
3. Designing
3:00 to 5:00 3:00 to 5:00 Wakade Pavan
22.09.2020 04.10.2020
4. Implement of Coding
3:00 to 5:00 3:00 to 5:00 Maske
5.10.2020 15.10.2020 Shubham
5. Testing of Project
3:00 to 5:00 3:00 to 5:00
18.10.2020 25.10.2020 Gaikwad
6. Deployment of Module
3:00 to 5:00 3:00 to 5:00 Shubham
1.11.2020 08.11.2020
7. Prepare Out Put
3:00 to 5:00 3:00 to 5:00
Prepare Report on 20.11.2020 30.11.2020
8.
Micro Project 3:00 to 5:00 3:00 to 5:00

6. Resources Used :

2
Sr.
No Name of Specification Quantity Remark
Resource/Material s
1 Personal computer Processor: Ryzen 3 3200g. Ram: 8GB
DDR4 3133MHz, HDD: 512GB

1 ____
2 Internet 10mbps BSNL LAN Network __ __
3 Java Development __ JDK is
Kit, Java Virtual the basic
Machine Java compiler java
compiler
(JDK , JVM) , which is
Notepad++ with very
nppexec plugin to easy to
compile and run use.

7. Names of Team Members :

Rahul Bhairu Fere


Wakade Pavan Govind
Maske Shubham Nagnath
Gaikwad Shubham Yuvraj

Plan B Outcomes after Execution

3
1. Rationale :
An electronic calculator is typically a portable electronic device used to
perform calculations, ranging from basic arithmetic to complex mathematics.

2. Brief Description :
The first solid-state electronic calculator was created in the early 1960s. Pocket-sized devices
became available in the 1970s, especially after the Intel 4004, the first microprocessor, was
developed by Intel for the Japanese calculator company Busicom. They later became used commonly
within the petroleum industry (oil and gas).
Modern electronic calculators vary from cheap, give-away, credit-card-sized models to sturdy
desktop models with built-in printers. They became popular in the mid-1970s as the incorporation
of integrated circuits reduced their size and cost. By the end of that decade, prices had dropped to the
point where a basic calculator was affordable to most and they became common in schools.
In addition to general purpose calculators, there are those designed for specific markets. For
example, there are scientific calculators which include trigonometric and statistical calculations.
Some calculators even have the ability to do computer algebra. Graphing calculators can be used to
graph functions defined on the real line, or higher-dimensional Euclidean space. As of 2016, basic
calculators cost little, but scientific and graphing models tend to cost more.

Uses of the Calculator :

A calculator is a device that performs arithmetic operations on numbers. The simplest


calculators can do only addition, subtraction, multiplication, and division. More sophisticated
calculators can handle exponent ial operations, roots, logarithm s, trigonometric functions, and
hyperbolic functions. Internally, some calculators actually perform all of these functions by repeated
processes of addition. Most calculators these days require electricity to operate. Portable, battery-
powered calculators are popular with engineers and engineering students. Before 1970, a more
primitive form of calculator, the slide rule , was commonly used. It consisted of a slat of wood,
called the slide, that could be moved in and out of a reinforced pair of slats. Both the slide and the
outer pair of slats had calibrated numerical scales. A movable, transparent sleeve called the cursor
was used to align numerals on the scales. The slide rule did not require any source of power, but its
precision was limited, and it was necessary to climb a learning curve to become proficient with it.

4
One of the most primitive calculators, the abacus is still used in some regions of the Far East. The
abacus uses groups of beads to denote numbers. Like the slide rule, the abacus requires no source of
power. The beads are positioned in several parallel rows, and can be moved up and down to denote
arithmetic operations. It is said that a skilled abacus user can do some calculations just as fast as a
person equipped with a battery-powered calculator.

As calculators became more advanced during the 1970s, they became able to make computations
involving variables (unknowns). These were the first personal computers. Today's personal
computers can still perform such operations, and most are provided with a virtual calculator program
that actually looks, on screen, like a handheld calculator. The buttons are actuated by pointing and
clicking.

Electronic calculators contain a keyboard with buttons for digits and arithmetical operations; some


even contain "00" and "000" buttons to make larger or smaller numbers easier to enter. Most basic
calculators assign only one digit or operation on each button; however, in more specific calculators, a
button can perform multi-function working with key combinations.

Display output

Calculators usually have liquid-crystal displays (LCD) as output in place of historical light-emitting


diode (LED) displays and vacuum fluorescent displays (VFD); details are provided in the
section Technical improvements.

3. Aim of the Micro-Project :


a) To give detailed information of how to create a calculator using java program.
b) To learn and teach about the different uses of the calculator in daily life
c) To describe about the functions and syntax used in java.
d) To give information about java language

4. Course outcome achieved :

a) Create a calculator app using java eclipse


b) Use a calculator app to perform deferent operation likes addition, division, subtraction,
multiplication and more.

5
5. Actual methodology followed :

Code :

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

public class MyCalculator extends Frame


{

public boolean setClear=true;


double number, memValue;
char op;

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.length];
MyMemoryButton memoryButton[]=new MyMemoryButton[memoryButtonText.length];
MySpecialButton specialButton[]=new MySpecialButton[specialButtonText.length];

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

6
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)
{
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);

tempX=TOPX;
y=TOPY+2*(HEIGHT+V_SPACE);
for(int i=0; i<memoryButton.length; i++)
{
memoryButton[i]=new MyMemoryButton(tempX,y,WIDTH,HEIGHT,memoryButtonText[i], this);
memoryButton[i].setForeground(Color.RED);
y+=HEIGHT+V_SPACE;
}

7
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;
}

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;}
}

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;
operatorButton[i]=new MyOperatorButton(tempX,y,WIDTH,HEIGHT,operatorButtonText[i], this);

8
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");
}
}

9
class MyDigitButton extends Button implements ActionListener
{
MyCalculator cl;

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)

10
{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)
{cl.displayLabel.setText(""+index);cl.setClear=false;}
else
cl.displayLabel.setText(cl.displayLabel.getText()+index);
}
}

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);

11
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;
}
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;

12
}
if(!opText.equals("="))
{
cl.number=temp;
cl.op=opText.charAt(0);
return;
}
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;
}

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

13
}

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;

14
case 'R':
cl.displayLabel.setText(MyCalculator.getFormattedText(cl.memValue));break;
case 'S':
cl.memValue=0.0;
case '+':
cl.memValue+=Double.parseDouble(cl.displayLabel.getText());
if(cl.displayLabel.getText().equals("0") || cl.displayLabel.getText().equals("0.0") )
cl.memLabel.setText(" ");
else
cl.memLabel.setText("M");
break;
}
}
}
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);

15
return Res;
}

public void actionPerformed(ActionEvent ev)


{
String opText=((MySpecialButton)ev.getSource()).getLabel();

if(opText.equals("Backspc"))
{
String tempText=backSpace(cl.displayLabel.getText());
if(tempText.equals(""))
cl.displayLabel.setText("0");
else
cl.displayLabel.setText(tempText);
return;
}
if(opText.equals("C"))
{
cl.number=0.0; cl.op=' '; cl.memValue=0.0;
cl.memLabel.setText(" ");
}
cl.displayLabel.setText("0");cl.setClear=true;
}
}

Output :

16
_________________________________________________________________________________

6. Action plan :

17
Name of
Sr. Planned Planned Responsible
Details of Activity
No. start Date Finish Date Team
Members
Gathering The Raw
25.08.2020 01.09.2020
1. Information Related
3:00 to 5:00 3:00 to 5:00
To Project
03.09.2020 05.09.2020
2. Analysis
3:00 to 5:00 3:00 to 5:00 Fere Rahul
14.09.2020 21.09.2020
3. Designing
3:00 to 5:00 3:00 to 5:00 Wakade Pavan
22.09.2020 04.10.2020
4. Implement of Coding
3:00 to 5:00 3:00 to 5:00 Maske
5.10.2020 15.10.2020 Shubham
5. Testing of Project
3:00 to 5:00 3:00 to 5:00
18.10.2020 25.10.2020 Gaikwad
6. Deployment of Module
3:00 to 5:00 3:00 to 5:00 Shubham
1.11.2020 08.11.2020
7. Prepare Out Put
3:00 to 5:00 3:00 to 5:00
Prepare Report on 20.11.2020 30.11.2020
8.
Micro Project 3:00 to 5:00 3:00 to 5:00

7. Actual Resources Used :

Sr.
No Name of Specification Quantity Remark
Resource/Material s
1 Personal computer Processor: Ryzen 3 3200g. Ram: 8GB
DDR4 3133MHz, HDD: 512GB

1 ____
2 Internet 10mbps BSNL LAN Network __ __
3 Java Development __ JDK is
Kit, Java Virtual the basic
Machine Java compiler java
compiler
(JDK , JVM) , which is
Notepad++ with very
nppexec plugin to easy to
compile and run use.

18
8. Skill Developed / Learning outcome of this Micro-Project:

 We learn that how to make the project of the menu driven programming in Java

 We learn that how to make the coding and programming.

 We learn that how to edit the program and how to do the presentation for the project.

 We learn that how to make the report for project.

 This all things we learn from the project.

9. Application of this Micro-Project:-

 To perform basic mathematical operations using this simple calculator

19

You might also like