0% found this document useful (0 votes)
3 views28 pages

Calculator Java

The document is a project report for an internship on creating a calculator using Java, submitted by Surathul Kamila S for a Bachelor of Engineering in Computer Science. It includes acknowledgments, a company profile of PCS Software Solutions, an overview of internship activities, and details about the project, including its objectives, system requirements, and coding examples. The project aims to enhance mathematical problem-solving through a software calculator that simplifies calculations and reduces human error.

Uploaded by

pcstech2021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views28 pages

Calculator Java

The document is a project report for an internship on creating a calculator using Java, submitted by Surathul Kamila S for a Bachelor of Engineering in Computer Science. It includes acknowledgments, a company profile of PCS Software Solutions, an overview of internship activities, and details about the project, including its objectives, system requirements, and coding examples. The project aims to enhance mathematical problem-solving through a software calculator that simplifies calculations and reduces human error.

Uploaded by

pcstech2021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

CALCULATOR USING JAVA

AN INTERNSHIP

PROJECT REPORT

Submitted by

SURATHUL KAMILA S
Register No. 952621104039

A report submitted in partial fulfillment of the requirements for the award of


Degree of

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE ENGINEERING

S.VEERASAMY CHETTIAR COLLEGE OF ENGINEERING


AND TECHNOLOGY, PULIYANGUDI-627 855

ANNA UNIVERSITY: CHENNAI -600 025

AUGUST 2024
S.VEERASAMY CHETTIAR COLLEGE OF ENGINEERING
AND TECHNOLOGY
ANNA UNIVERSITY: CHENNAI- 600 025

S.V.Nagar, Puliyangudi, Tamilnadu, India.

DEPARTMENT OF COMPUTER SCIENCE

BONAFIDE CERTIFICATE

Certified that this project “CALCULATOR USING JAVA” is the bonafide of


“SURATHUL KAMILA S” who carried out the project work under our supervision.

Internship Coordinator Head of the Department

Miss.Janani Mr.

Software Developer, Assistant Professor

PCS Software Solutions, S,Veerasamy Chettiar College of

Surandai-627859. Engineering And Technology,

Puliyangudi -627 855


AKCNOWLEDGEMENT

Firstly, I express my heartiest thanks and gratefulness to almighty God for His divine
blessing makes us possible to complete the project work successfully.

I really grateful and wish my profound my indebtedness to Supervisor

Miss.Janani, Software Developer, PCS Software Solutions, Surandai-627859. Deep


Knowledge & keen interest of my supervisor in the field of web development has helped
me enormously to carry out this project. Her endless patience, scholarly guidance,
continual encouragement, constant and energetic supervision, constructive criticism,
valuable advice, reading many inferior drafts and correcting them at all stage have made it
possible to complete this project.

I would like to express my heartiest gratitude to Mr.xxxxxx, Department of CSE, for his
kind help to finish my project.

I would also generously welcome each one of those individuals who have helped me
straight forwardly or in a roundabout way in making this project a win. In this unique
situation, I might want to thank the various staff individuals, both educating and non-
instructing, which have developed their convenient help and facilitated my undertaking.

Finally, I must acknowledge with due respect the constant support and patients of my
parents.

SURATHUL KAMILA S

(952621104039)
TABLE OF CONTENTS

Content Page No.

CERTIFICATE

AKCNOWLEDGEMENT
TABLE OF CONTENTS
ABSTRACT 5
CHAPTER 1 COMPANY PROFILE 6
CHAPTER 2 WEEKLY OVERVIEW OF INTERNSHIP ACTIVITIES 8
CHAPTER 3 INTRODUCTION 10
CHAPTER 4 SYSTEM SPECIFICATION 13
CHAPTER 5 TECHNOLOGY LEARNT 14
CHAPTER 6 PROJECT DESCRIPTION 15
CHAPTER 7 CODING 17

CHAPTER 8 RESULTS 26
CHAPTER 9 CONCLUSION 27
CHAPTER 10 REFERENCES 28
CALCULATOR USING JAVA

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.
CHAPTER 1
COMPANY PROFILE

PCS Software Solutions is an independent software development and training


company, driven by industry experts and thought leaders in Web/Mobile
development and training domain. We work with some of the smartest software-
driven businesses around the world including software product start-ups as well
as MNC over 50 companies. We offer Website Development and Hosting
Services at affordable price. We develop the Website and as well as take over
the responsibility of maintaining your Website PCS offers the most effective
and result oriented Digital / Online Marketing Strategies for clients to establish
a good image of their brand in the Digital and Social Media. With keen industry
expertise and market knowledge, we will analyze the targeted audience to
determine the best way of business promotion through Digital Marketing using
various Online Promotions in Google, Facebook, Instagram & Youtube
Promotions.

VISION:
Be a global force in innovative solutions, quality excellence and redefine
creative thoughts. Striving to be a global force in innovative solutions, quality
excellence, and the redefinition of creative thoughts, we embark on a journey
that transcends boundaries. Our commitment extends beyond mere problem-
solving; it encompasses a vision to reshape industries and leave an indelible
mark on the global landscape. At the core of our mission is a relentless pursuit
of innovation, where we challenge the status quo and push the limits of what is
conceivable
MISSION:
We endeavour to bring innovative solutions to the forefront, employing
a simple yet effective approach that underscores our commitment to providing
deserving quality. Our mission is rooted in a dedication to pushing the
boundaries of what's possible, embracing creativity, and maintaining a relentless
pursuit of excellence. By adhering to these principles, we aim to not only meet
but exceed the expectations of our users, clients, and partners. Through a
combination of forward-thinking strategies and a focus on quality, we strive to
make a meaningful impact in every endeavour we undertake.

OUR SERVICES

 WEBSITE DEVELOPMENT

 MOBILE APPLICATION DEVELOPMENT

 E-COMMERCE

 WORDPRESS DEVELOPMENT

 OUTSOURCING

 CLOUD SERVICES

 DIGITAL MARKETING

 SEO

 COLLEGE PROJECT

 INTERNSHIP
 SOFTWARE TRAINING

CHAPTER 2
WEEKLY OVERVIEW OF INTERNSHIP
ACTIVITIES

DATE DAY NAME OF THETOPIC/MODULE


COMPLETED
1st WEEK

08/07/2024 Monday Introduction About JAVA & Set up

09/07/2024 Tuesday Datatypes & Variables

10/07/2024 Wednesday Operators

11/07/2024 Thursday Object Class

12/07/2024 Friday Strings

DATE DAY NAME OF THETOPIC/MODULE


COMPLETED
15/07/2024 Monday Control flow statements
2nd WEEK

16/07/2024 Tuesday JAVA Inheritance

18/07/2024 Thursday Polymorphism


19/07/2024 Friday Task
DATE DAY NAME OF THETOPIC/MODULE
COMPLETED

3rd WEEK 22/07/2024 Monday Abstraction

23/7/2024 Tuesday Encapsulation

24/07/2024 Wednesday Array

25/07/2024 Thursday OOPS


26/07/2024 Friday Task

DATE DAY NAME OF THETOPIC/MODULE


COMPLETED
4th WEEK

30/07/2024 Monday Regex

31/07/2024 Tuesday Exception Handling

01/08/2024 Wednesday Multithreading

02/08/2024 Thursday Synchronization


03/08/2024 Friday Task & Live Project Explanation
DATE DAY NAME OF THETOPIC/MODULE
COMPLETED
5th WEEK

5/08/2024 Monday Project Requirement Analysis

6/08/2024 Tuesday Modules development

07/08/2024 Wednesday Debugging


08/08/2024 Thursday Project Completion

CHAPTER 3

INTRODUCTION

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.

1.1Internship Objectives
 Internships are generally thought of to be reserved for college students looking
to gain experience in a particular field. However, a wide array of people can
benefit from Training Internships in order to receive real world experience and
develop their skills.
 An objective for this position should emphasize the skills you already possess in
the area and your interest in learning more
 Internships are utilized in a number of different career fields, including
architecture, engineering, healthcare, economics, advertising and many more.
 Some internship is used to allow individuals to perform scientific research while
others are specifically designed to allow people to gain first-hand experience
working.
 Utilizing internships is a great way to build your resume and develop skills that
can be emphasized in your resume for future jobs. When you are applying for a
Training Internship, make sure to highlight any special skills or talents that can
make you stand apart from the rest of the applicants so that you have an
improved chance of landing the position.

1.1 MOTIVATION FOR INTERNSHIP

My motivation for this internship was rooted in a desire to learn about


Software development, gain practical experience, and contribute to
meaningful projects. This experience not only aimed to solidify my
technical expertise but also to prepare me for a successful career in an
ever-evolving technological landscape.

The motivation behind pursuing this internship was driven by my


passion for combining web development to create efficient, secure, and
user-friendly Web Applications. In an increasingly interconnected
digital world, the synergy between front-end development and back-end
development is crucial for delivering seamless online experiences. I
recognized that gaining practical experience in both domains would be
instrumental in advancing my career and contributing meaningfully to
the tech industry.
From a software development perspective, my interest in JAVA
stemmed from the desire to build interactive and aesthetically pleasing
web interfaces. However, I also understood that even the most
beautifully designed Web applications require a Programming language
like JavaScript to create dynamic websites.
The decision to undertake this internship was further motivated by the
opportunity to work in a professional setting, where I could apply my
theoretical knowledge to real-world scenarios. I was eager to face the
challenges and complexities of integrating web development with
network management, learning from industry experts, and gaining
hands-on experience with cutting-edge technologies.

Additionally, I was motivated by the prospect of contributing to


projects that have a tangible impact on users and organizations. The chance
to enhance network performance, implement security protocols, and ensure
high availability of applications aligned with my long-term career goals of
becoming a proficient full-stack developer with a strong foundation in
JAVA.
This internship also offered a platform to develop essential soft skills
such as teamwork, problem- solving, and project management.
Collaborating with professionals from diverse backgrounds and
working on interdisciplinary projects provided a holistic learning
experience that extended beyond technical knowledge.

In summary, my motivation for this internship was rooted in a desire to


bridge the gap between software developments, gain practical
experience, and contribute to meaningful projects. This experience not
only aimed to solidify my technical expertise but also to prepare me for
a successful career in an ever-evolving technological landscape.
CHAPTER 4

SYSTEM REQUIREMENTS

The software requirement specification can produce at the culmination of


the analysis task. The function and performance allocated to software as part of
system engineering are refined by established a complete information
description, a detailed functional description, a representation of system
behavior, and indication of performance and design constrain, appropriate
validate criteria, and other information pertinent to requirements.

Software Requirements:
Text Editor : Visual Studio.
Language : JAVA.
Operating System : Windows 10.
Hardware Requirements:
Processor : Intel core i3
Memory : 8GB RAM
Hard Disk : 1TB

CHAPTER 5

TECHNOLOGY LEARNT

JAVA

 Java is a popular programming language.

 Java is used to develop mobile apps, web apps, desktop apps, games and
much more.

 Java works on different platforms (Windows, Mac, Linux, Raspberry Pi,


etc.)

 It is one of the most popular programming languages in the world

 It has a large demand in the current job market

 It is easy to learn and simple to use

 It is open-source and free

 It is secure, fast and powerful

 It has huge community support (tens of millions of developers)


 Java is an object oriented language which gives a clear structure to
programs and allows code to be reused, lowering development costs

 As Java is close to C++ and C#, it makes it easy for programmers to


switch to Java or vice versa.

CHAPTER 6
PROJECT DESCRIPTION

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.

Java Server

In this Java Server, we are performing simple calculations example addition,


subtraction, etc. In this Code first, we receive input from the client-side. We
pass this information to the “Stringtokenizer class” this class help to extract the
exact “operand and operation” to perform the operation. when the result is ready
java server sends it back to the result client

Existing System

Before software calculators were invented, calculators were physical machines


with buttons for digits and operations, and a small display for inputs and
results. It may have lower arithmetic proficiency and may perform worse in
math. Circular slide rules can be difficult to use because it can be hard to find
figures on the dish. They also have a limited number of scales, and less
important scales are closer to the centre and have lower precision.

Proposed System

Modern scientific calculators have many more capabilities than the original
four- or five-function calculator. These capabilities include scientific notation,
logarithmic functions, trigonometric functions, exponential functions, and more.
Software calculators can provide accurate results without the risk of human
error. This is especially important in financial planning, where even small errors
can have a big impact.
CHAPTER 7

CODING

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


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++)
{
memoryButton[i]=new MyMemoryButton(tempX,y,WIDTH,HEIGHT,memoryButtonText[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[], t
his);
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;
operatorButton[i]=new MyOperatorButton(tempX,y,WIDTH,HEIGHT,operatorButtonText[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;

//////////////////////////////////////////
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)
{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;
}
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));
//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());
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"))
{
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

CHAPTER 8

RESULTS
CHAPTER 9
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.

FUTURE ENHANCEMENT

Future Work of this project is listed below


 Menu bar
 Scientific calculation
 Coding for +/- button

CHAPTER 10
REFERENCES
 https://www.w3schools.com/java/java_intro.asp

 https://ieeexplore.ieee.org/document/475332
 https://ieeexplore.ieee.org/xpl/RecentIssue.jsp?punumber=85
 https://ieeexplore.ieee.org/xpl/conhome/9648913/proceeding

You might also like