Professional Documents
Culture Documents
Project Report
Of
Summer Training Project At
On
BASIC CALCULATOR
Submitted
In The partial fulfilment of
Bachelor of Technology
Department Of Computer Science and Engineering
Submitted By:
Name:
AZHAR MIZAN
5th
ACKNOWLEDGEMENT
Gratitude is not a thing of expression. It is more matter of feeling.
There is always a sense of gratitude towards for their help and supervision in
achieving the goals. The formal piece of acknowledgement is an attempt to
express the feeling of gratitude towards people who helpful me in successfully
completing of my training.
Above all no words can express my feelings to my parents. Friends all those
person who supported me during my project. I am also thankful to all the
responders whose cooperation & support has helped me a lot in collecting
necessary information.
Table of Content
Content
page no.
Cover page..... 1
Training Certificate.. 2
Acknowledgement. 3
Table of content............. 4
Company profile. 7
Abstract.
1. Introduction
1.1 Project Overview.
1.2 Java Overview ......................................................................... 15
1.3 History of Java: ......................................................................................... 16
1.4 Tools you will need: .................................................................................. 16
2. Java Environment setup:.
3. Design model:.
4. Java Basic Syntax ....................................................................
4.1 Java Identifiers: ........................................................................................ 20
6. Main Project
6.1 Project preview
6.2 Project code
6.2.1 Running state snapshot
What is an Event?
Types of Event 86
What is Event Handling?
Callback Methods
Company profile
Internshala is a dot com business with the heart of dot org.
At the core of the idea is the belief that internships, if managed well, can make
a positive difference to the student, to the employer, and to the society at
large. Hence, the ad-hoc culture surrounding internships in India should and
would change. Internshala aims to be the driver of this change.
Internshala is different things to different people-
For million plus students struggling to get a meaningful internship every year,
Internshala is a friend, a mentor, an affectionate senior, and a boon.
Introduction
This document presents the System Architecture of Calculator project implemented in swing (Java).
The System Architecture described would be used for development of the product and
will be used as an input to the various development and testing phases of the Software
Development Lifecycle.
This document is also comprising of the topics I covered during my training period. Each and every
topic is described briefly and efficiently. Topics are observed carefully and large amount of
knowledge is gained from each and every point denoted in the document field. As well as coding is
also done for the corresponding coding topic I studied.
This document also have the brief denotation of the Tools I used at the Internshala
for various works. Every tool written over here is learned by the practical usage in the company.
The document is broken into three main sections: The Main Project, Topics I studied during
Training, and Tools I used during Training. The Main project represents the high level view of the
system as a box, depicting various interacting blocks belonging to its execution environment. Topics
I studied during Training is further drilled down to logically define each and every topic I studied
during my training period.
These topics cover the area related to Project as well as for general studies of the Technical
information. Finally, The Tools I used during Training, which outlines various tools I used during
my training period for observation of code, doing review work and entering the details of the daily
work done.
This would document the methodology being anticipated for achieving the non-functional goals of
an expected functionality.
1. Introduction
1.1
Project Overview
Can be used to perform any process that consists of a sequence of steps each of which applies
one of these operations.
Have no purpose other than these processes, because the operations are the sole, or at least
the primary, features of the calculator, rather than being secondary features that support other
functionality that is not normally known simply as calculation.
1.2
Java Overview
Java programming language was originally developed by Sun Microsystems which was initiated
by James
Gosling and released in 1995 as core component of Sun Microsystems Java platform (Java 1.0
[J2SE]).
As of December 2008, the latest release of the Java Standard Edition is 6 (J2SE). With the
advancement of Java
Its widespread popularity, multiple configurations were built to suite various types of platforms.
Ex: J2EE for
8
Sun Microsystems has renamed the new J2 versions as Java SE, Java EE and Java ME,
respectively. Java is
Java is:
Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based
on the
Object model.
Platform independent: Unlike many other programming languages including C and C++, when
Java is
Compiled, it is not compiled into platform specific machine, rather into platform independent byte
code.
This byte code is distributed over the web and interpreted by virtual Machine (JVM) on
whichever platform
It is being run.
Simple Java is designed to be easy to learn. If you understand the basic concept of OOP,Java
would be
Easy to master.
Secure: With Java's secure feature, it enables to develop virus-free, tamper-free systems.
Authentication
The compiled code to be executable on many processors, with the presence of Java runtime
system.
specification makes Java portable. Compiler inJava is written in ANSI C with a clean portability
boundary
1.3
History of Java
James Gosling initiated the Java language project in June 1991 for use in one of his many settop box projects.The language, initially called Oak after an oak tree that stood outside Gosling's
office, also went by the namGreen and ended up later being renamed as Java, from a list of
random words Sun released the first public implementation as Java 1.0 in 1995. It promised
Write Once, Run Anywhere (WORA), providing no-cost run-times on popular platforms.On 13
November 2006, Sun released much of Java as free and open source software under the terms
of the GNU General Public License (GPL).On 8 May 2007, Sun finished the process, making all
of Java's core code free and open-source, aside from a small portion of code to which Sun did
not hold the copyright.
1.4
Tools Used
For performing the examples discussed in this tutorial, you will need a Pentium 200-MHz
computer with a minimum of 64 MB of RAM (128 MB of RAM recommended).You also will need
the following softwares:
Linux 7.1 or Windows 95/98/2000/XP operating system.
Java JDK 5
Microsoft Notepad or any other text editor
This tutorial will provide the necessary skills to create GUI, networking, and Web applications
using Java.
Before we proceed further, it is important that we set up the Java environment correctly. This
section guides you on how to download and set up Java on your machine. Please follow the
following steps to set up the environment.Java SE is freely available from the link Download
Java. So you download a version based on your operation system.Follow the instructions to
download Java and run the .exe to install Java on your machine. Once you installed Java on
10
your machine, you would need to set environment variables to point to correct installation
directories:
Setting up the path for windows 2000/XP:
Assuming you have installed Java in c:\Program Files\java\jdk directory:
Right-click on 'My Computer' and select 'Properties'.
Click on the 'Environment variables' button under the 'Advanced' tab.
Now, alter the 'Path' variable so that it also contains the path to the Java executable. Example,
if the path is
currently set to 'C:\WINDOWS\SYSTEM32', then change your path to read
'C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin'.
2. Design model
Project is developing over the Waterfall model of SDLC life cycle. Currently the HSAN project is going
on High level Design of Design face.
Waterfall model consist of following phases-
11
1- RequirementsAll requirements specification from first phase are studied in this phase and system design
is prepared. System design helps in specifying hardware and system requirements and also
helps in defining overall system architecture.
2- System DesignThe requirement specifications from first phase are studied in this phase and system design
is prepared. System Design helps in specifying hardware and system requirements and also
helps in defining overall system architecture.
3- Coding OR ImplementationWith inputs from system design, the system is first developed in small programs called
units, which are integrated in the next phase. Each unit is developed and tested for its
functionality which is referred to as Unit Testing.
4- Integration and TestingAll the units developed in the implementation phase are integrated into a system after
testing of each unit. Post integration the entire system is tested for any faults and failures.
12
5- Development of systemOnce the functional and non-functional testing is done, the product is deployed in the
customer environment or released into the market.
6- MaintenanceThere are some issues which come up in the client environment. To fix those issues patches
are released. Also to enhance the product some better versions are released. Maintenance is
done to deliver these changes in the customer environment.
Advantage
The advantage of waterfall development is that it allows for departmentalization and control. A
schedule can be set with deadlines for each stage of development and a product can proceed through
the development process model phases one by one.
Development moves from concept, through design, implementation, testing, installation,
troubleshooting, and ends up at operation and maintenance. Each phase of development proceeds
in strict order.
Disadvantage
The disadvantage of waterfall development is that it does not allow for much reflection or revision.
Once an application is in the testing stage, it is very difficult to go back and change something that
was not well-documented or thought upon in the concept stage.
13
All Java components require names. Names used for classes, variables and methods are called
identifiers.In Java, there are several points to remember about identifiers. They are as follows:
All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore
(_).
After the first character, identifiers can have any combination of characters.
A keyword cannot be used as an identifier.
Most importantly identifiers are case sensitive.
Examples of legal identifiers: age, $salary, _value, __1_value
Examples of illegal identifiers: 123abc, -salary
Like other languages, it is possible to modify classes, methods, etc., by using modifiers. There are
two categories of modifiers:
Access Modifiers: default, public, protected, private
Non-access Modifiers: final, abstract, strictfp
We will be looking into more details about modifiers in the next section.
15
In this chapter, we will look into the concepts Classes and Objects.
Object - Objects have states and behaviors. Example: A dog has states-color, name, breed as well
as behaviors -wagging, barking, eating. An object is an instance of a class.
Class - A class can be defined as a template/blue print that describes the behaviors/states that
object of its type support.
4.1.
Objects in Java:
Let us now look deep into what are objects. If we consider the real-world we can find many objects
around us, Cars, Dogs, Humans, etc. All these objects have a state and behavior. If we consider a dog,
then its state is - name, breed, color, and the behavior is - barking, wagging, running If you compare
the software object with a real world object, they have very similar characteristics.
Software objects also have a state and behavior. A software object's state is stored in fields and
behavior is shown via methods. So in software development, methods operate on the internal state
of an object and the object-to-object communication is done via methods.
void sleeping(){
}
}
A class can contain any of the following variable types.
Local variables: Variables defined inside methods, constructors or blocks are called local variables.
The variable will be declared and initialized within the method and the variable will be destroyed
when the method has completed.
Instance variables: Instance variables are variables within a class but outside any method. These
variables are instantiated when the class is loaded. Instance variables can be accessed from inside
any method,constructor or blocks of that particular class.
Class variables: Class variables are variables declared within a class, outside any method, with the
static keyword. A class can have any number of methods to access the value of various kinds of
methods. In the above example,barking(), hungry() and sleeping() are methods.
6. Main Project
6.1 Project preview
Can be used to perform any process that consists of a sequence of steps each of which applies
one of these operations.
Have no purpose other than these processes, because the operations are the sole, or at least
the primary, features of the calculator, rather than being secondary features that support other
functionality that is not normally known simply as calculation.
18
The results include numerical calculators that apply arithmetic operations or mathematical functions
to numbers, and that produce numerical results or graphs of numerical functions, plus some nonnumerical tools and games that are also called calculators.
Many of the results are calculators that do not imitate or simulate hardware calculators, but that take
advantage of the greater power of computer software to implement alternative types of calculators.
Software calculators are provided on the Internet which are customizable to use any conceivable
algebraic expression.
These user-customizable software calculators can also be used in conjunction with formula or
equation creation capabilities so that the software calculator can now be created to perform all
possible mathematical functions. No longer limited to a set of trigonometric and simple algebraic
expressions, versions of the software calculator are now tailored to any and all topical applications.
19
{"7","8","9","+","4","5","6","-
displayDimension
new
Dimension
Dimension(dimW[1],dimH[1]);
regularDimension
new
Dimension
Dimension(dimW[2],dimH[1]);
rColumnDimension
new
Dimension
Dimension(dimW[3],dimH[1]);
zeroButDimension
new
setDefaultCloseOperation(EXIT_ON_CLOSE);
GridLayout grid = new GridLayout(5,5);
setLayout(grid);
for(int i=0;i<4;i++)
function[i] = false;
add(row[0]);
for(int i=0;i<4;i++)
row[1].add(button[i]);
add(row[1]);
for(int i=4;i<8;i++)
row[2].add(button[i]);
add(row[2]);
for(int i=8;i<12;i++)
row[3].add(button[i]);
add(row[3]);
row[4].add(button[17]);
for(int i=12;i<14;i++)
row[4].add(button[i]);
row[4].add(button[17]);
add(row[4]);
row[5].add(button[14]);
row[5].add(button[15]);
row[5].add(button[16]);
add(row[5]);
setVisible(true);
}
}
}
if(temp1.contains("-")){
String [] temp11 = temp1.split("-",2);
temporary[1]
(Double.parseDouble(temp11[1])*-1);
}
}catch(ArrayIndexOutOfBoundsException e){}
try{
if(function[2]==true)
result = temporary[0]*temporary[1];
else if(function[3]==true)
result = temporary[0]/temporary[1];
else if(function[0]==true)
result = temporary[0]+temporary[1];
else if(function[1]==true)
result = temporary[0]-temporary[1];
display.setText(Double.toString(result));
for(int i=0;i<4;i++)
function [i] = false;
}catch(NumberFormatException e){}
}
}catch(Exception e){}
24
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==button[0])
display.append("7");
if(e.getSource()==button[1])
display.append("8");
if(e.getSource()==button[2])
display.append("9");
if(e.getSource()==button[3]){
temporary[0] = Double.parseDouble(display.getText());
function[0] = true;
//display.setText("");
}
if(e.getSource()==button[4])
display.append("4");
if(e.getSource()==button[5])
display.append("5");
if(e.getSource()==button[6])
display.append("6");
if(e.getSource()==button[7]){
temporary[0] = Double.parseDouble(display.getText());
function[1] = true;
//display.setText("");
}
if(e.getSource()==button[8])
display.append("1");
if(e.getSource()==button[9])
display.append("2");
if(e.getSource()==button[10])
display.append("3");
25
if(e.getSource()==button[11]){
temporary[0] = Double.parseDouble(display.getText());
function[2] = true;
//display.setText("");
}
if(e.getSource()==button[12])
display.append(".");
if(e.getSource()==button[13]){
temporary[0] = Double.parseDouble(display.getText());
function[3] = true;
//display.setText("");
}
if(e.getSource()==button[14])
clear();
if(e.getSource()==button[15])
getSqrt();
if(e.getSource()==button[16])
getPosNeg();
if(e.getSource()==button[17])
getResult();
if(e.getSource()==button[17])
display.append("0");
}
public static void main(String s[]){
new Calculator();
}
}
26
Memory Operation
The calculator has one memory that can be used for storing values temporarily. To clear the memory
(set it's value to 0), press the key 'MC'. To recall the value stored in memory use the key 'MR'. To
add to the value in memory, press 'M+'. To subtract a value from the memory use the key 'M-'.
Percentages
The Simple Virtual Calculator can be used to calculate percentages even though it doesn't have a
'%' key. Read how on this document: Percentage.
27
Swing is a GUI widget toolkit for Java. It is part of Oracle's Java Foundation Classes (JFC)
an API for providing a graphical user interface (GUI) for Java programs.
Swing was developed to provide a more sophisticated set of GUI components than the
earlier Abstract Window Toolkit (AWT). Swing provides a native look and feel that emulates the look
and feel of several platforms, and also supports apluggable look and feel that allows applications to
have a look and feel unrelated to the underlying platform. It has more powerful and flexible
components than AWT. In addition to familiar components such as buttons, check boxes and labels,
Swing provides several advanced components such as tabbed panel, scroll panes, trees, tables, and
lists.
Unlike AWT components, Swing components are not implemented by platform-specific code.
Instead, they are written entirely in Java and therefore are platform-independent. The term
"lightweight" is used to describe such an element.[1]
Swing is currently in the process of being replaced by JavaFX.
Provides a set of "lightweight" (all-Java language) components that, to the maximum degree
possible, work the same on all platforms.
28
Change in the state of an object is known as event i.e. event describes the change in state of
source. Events are generated as result of user interaction with the graphical user interface
components. For example, clicking on a button, moving the mouse, entering a character through
keyboard,selecting an item from list, scrolling the page are the activities that causes an event to
happen.
Types of Event .......................................................................................................................................
86
The events can be broadly classified into two categories:
Foreground Events - Those events which require the direct interaction of user.They are generated
as consequences of a person interacting with the graphical components in Graphical User Interface.
For example, clicking on a button, moving the mouse, entering a character through
keyboard,selecting an item from list, scrolling the page etc.
29
Background Events - Those events that require the interaction of end user are known as background
events. Operating system interrupts, hardware or software failure, timer expires, an operation
completion are the example of background events.
The Delegation Event Model has the following key participants namely:
Source - The source is an object on which event occurs. Source is responsible for providing
information of the occurred event to it's handler. Java provide as with classes for source
object.
The benefit of this approach is that the user interface logic is completely separated from the logic that
generates the event. The user interface element is able to delegate the processing of an event to the
separate piece of code. In this model ,Listener needs to be registered with the source object so that
the listener can receive the event notification. This is an efficient way of handling the event because
the event notifications are sent only to those listener that want to receive them.
30
1.
Now the object of concerned event class is created automatically and information about the source
and the event get populated with in same object.Event object is forwarded to the method of registered
listener class.The method is now get executed and returns.
The User clicks the button and the event is generated.
These are the methods that are provided by API provider and are defined by the application
programmer and invoked by the application developer. Here the callback methods represents an
event method. In response to an event java jre will fire callback method. All such callback methods
are provided in listener interfaces.
If a component wants some listener will listen to it's events the the source must register itself to the
listener.
31
Bibliography
1234567-
http://www.tutorialspoint.com/sdlc/sdlc_waterfall_model.htm
https://sites.google.com/site/amitsciscozone/home/gpon/gpon-fundamentals
https://en.wikipedia.org/wiki/Line_card
https://en.wikipedia.org/wiki/Fiber_optic_splitter
http://searchtelecom.techtarget.com/definition/passive-optical-network
https://en.wikipedia.org/wiki/Optical_line_termination
http://courses.cs.washington.edu/courses/cse451/10au/tutorials/tutorial_ctags.ht
ml
8- http://vim.wikia.com/wiki/Cscope
9- http://www.tutorialspoint.com/makefile/
10- http://www.tutorialspoint.com/svn/svn_basic_concepts.htm
11- http://www.softpanorama.org/Utilities/teraterm.shtml
12- https://en.wikipedia.org/wiki/PuTTY
13- http://www.tutorialspoint.com/data_communication_computer_network/data_link
_layer_introduction.htm
14- http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
15- http://www.linux-tutorial.info/modules.php?name=MContent&pageid=268
16- http://www.comptechdoc.org/os/linux/programming/c/linux_pgcmutex.html
17- http://www.9tut.com/virtual-local-area-network-vlan-tutorial
18- http://www.guru99.com/jira-tutorial-a-complete-guide-for-beginners.html
19- https://en.wikipedia.org/wiki/Vim_(text_editor)
32