NPS INTERNATIONAL CHENNAI
PROJECT
YEAR: 2018-19
NAME :SIDDHARTHA MUKHERJEE
GRADE :X
ROLL NO : 30
SUBJECT : COMPUTER APPLICATIONS
TOPICS : PROJECT
1
CALCULATOR
ACKNOWLEDGEMENT
2
First and foremost, I would like to thank the ICSE board for
giving me this wonderful opportunity to do this project. It has
truly been an efficacious experience.
I owe a debt of gratitude to our Principal, Mrs. Sudha Balan for
her unfailing support and encouragement throughout the
duration of this project.
For her indispensible guidance and counsel, my heartfelt
thanks to our exceptional Computer Science teacher at NPSI,
Mrs. Jeba Andrew.
Last but definitely not the least; I would like to thank my family
for their unfailing support and endorsement throughout.
INDEX
3
SERIAL.N TOPIC Page No
O
SYNOPSIS
1. I. OBJECTIVE 5
II. INTRODUCTION 5
III. WHY DID I DO 5
THIS PROGRAM
2. JAVA
PROGRAMMING 6
LANGUAGE
WHY DID I USE JAVA
3. FEATURES USED
I. DO-WHILE LOOP 6
II. SWITCH CASE 6
6
III. HARDWARE 6
REQUIREMENT
IV. SOFTWARE
REQUIREMENT
4. PACKAGES USED 7
5. ALGORITHM 7
6. PROGRAM 8
7. SCREENSHOT 16
USER MANUAL
8. I. STEP BY STEP 18
GUIDE
4
9. BIBLIOGRAPHY 19
SYNOPSIS
OBJECTIVE
The objective of my program is to create a calculator and perform functions
depending on the choices made by the user. The entire program is user depended,
meaning that the program would only flow depending on the choices made by the
users.
INTRODUCTION
Calculator is one of the most simple device used for mathematical calculations
such as addition,subtraction etc.
There are several details that the user would have to enter, such as:
1. Enter the No of the function which the user wants to perform.
2. Enter a value or two values depending on the function chosen by the user.
3. The desired result will appear as output on the screen.
4. Enter ‘0’ to use calculator again or any other number to exit.
WHY DID I DO THIS PROGRAM?
Calculator is one of the most popular devices used across the world.I wanted to
create a calculator in a program which would help users to just input data and
receive output.
JAVA PROGRAMMING LANGUAGE
5
Java is a programming language (Technology). It was first developed by James
Gosling at Sun Microsystems, which is now a part ofOracle Corporation. It was
released in 1995 as a part of Sun Microsystems' Java platform. The language has
developed much of itssyntax from C and C++. Java can run on many
different operating systems. This makes Java platform independent. Java does this
by making the Javacompiler turn code into Java bytecode instead of machine code.
This means that when the program is executed, the Java Virtual Machine interprets
the bytecode and translates it into machine code.
WHY DID I USE JAVA ?
1. JAVAis a very user friendly programing language whose functions and
operations are very easy to learn and use.
[Link] is an object oriented programming which makes the whole program
modular, flexible and extensible.
[Link] is platform independent,meaning that the user can run my program in
whatever system that he prefers. He/she is not restricted to one particular operating
system.
[Link] I could use several operations and features(such as arrays) in a
modular and systematic manner.
FEATURES USED
1. Do- while loop-It is used to keep the program running as long as the user
wants to.
2. Switch case-It helps in functioning the program according to the users
choice.
Hardware requirements
Minimum: 64Mb main memory, Pentium II processor or equivalent
Recommended: 128Mb main memory, 400MHz Pentium III processor or above
6
Software requirements
J2SE 1.4.2 (Java 2 SDK version 1.4.2) or newer must be installed.
BlueJ versions up to version 1.3.0 also run on JDK 1.3.x.
BlueJ versions up to version 1.1.3 also run on JDK 1.2.2
PACKAGES USED
For my project I used [Link] package. I used “util” package in order to utilize its
features,especially it’s input features.
I used “util” package as my program comprises mainly of users input, hence
making the package very necessary .I preferred the util package over
the“io”(input/output package) as I felt that the former made the whole program
simple and well organized.
ALGORITHM
STEP 1:Start of algorithm
STEP 2:The program offers the user to choose any function among fourteen of
them.
STEP 3:The program then asks the user to enter to enter the set of values.
STEP 4:The output of the program will be visible in the output screen.
STEP 5:The program offers the user the option to use the calculator again or exit.
STEP 6:Depending on the output of the user the program exits or offers the user to
use the calculator again
7
PROGRAM
[Link].*;
[Link].*;
class Calculator
public static double N1,N2,Res;
public static intCh,Exit=0;
public static Scanner in = new Scanner([Link]);
public static void main()
while(Exit==0)
[Link]('\f');
[Link]("This is a calculator. The various functions listed below can be performed:");
[Link]("--------------------------------------------------------------------------");
[Link]();
[Link]("[Link] [Link] a number off to the nearest integer");
[Link]("[Link] [Link] the sine of an angle ");
[Link]("[Link] [Link] the cosine of an angle ");
[Link]("[Link] [Link] the tangent of an angle ");
8
[Link]("[Link] a number [Link] the smaller of two numbers");
[Link]("[Link] a number to a power [Link] the larger of two numbers ");
[Link]("[Link] a number's square root [Link] the absolute value of a number ");
[Link]();
[Link]("Enter your choice by pressing the number it corresponds to");
Ch = [Link]();
switch(Ch)
case 1:
[Link]("Enter two numbers");
N1 = [Link]();
N2 = [Link]();
[Link]("Sum of "+N1+" and "+N2+" = "+(N1+N2));
break;
case 2:
[Link]("Enter the number from which you wish to subtract.");
N1 = [Link]();
[Link]("Enter the number you wish to subtract from "+N1);
N2 = [Link]();
[Link]("Difference between "+N1+" and "+N2+" = "+(N1-N2));
break;
9
case 3:
[Link]("Enter 2 numbers.");
N1 = [Link]();
N2 = [Link]();
[Link]("Product of "+N1+" and "+N2+" = "+(N1*N2));
break;
case 4:
[Link]("Enter the number which you wish to divide.");
N1 = [Link]();
[Link]("Enter the number you wish to divide "+N1+" with.");
N2 = [Link]();
[Link]("Quotient: "+(N1/N2));
[Link]("Quotient: "+(N1%N2));
break;
case 5:
[Link]("Enter a number.");
N1 = [Link]();
[Link]("Square of N1 = "+(N1*N1));
break;
10
case 6:
[Link]("Enter the base first and then the index.");
N1 = [Link]();
N2 = [Link]();
[Link](N1+" to the power of "+N2+" = "+([Link](N1,N2)));
break;
case 7:
[Link]("Enter a number.");
N1 = [Link]();
[Link]("Square root of "+N1+" = "+ ([Link](N1)));
break;
case 8:
[Link]("Enter a number.");
N1 = [Link]();
[Link](N1+" can be rounded off to "+ ([Link](N1)));
break;
case 9:
[Link]("Enter an angle.");
11
N1 = [Link]();
if(N1>=0.0 && N1 <= 90.0)
[Link]("Sine of "+N1+"° = "+([Link](N1)));
else
[Link]("Invalid angle entered.");
break;
case 10:
[Link]("Enter an angle.");
N1 = [Link]();
if(N1>=0.0 && N1 <= 90.0)
[Link]("Cosine of "+N1+"° = "+([Link](N1)));
else
[Link]("Invalid angle entered.");
break;
12
case 11:
[Link]("Enter an angle.");
N1 = [Link]();
if(N1>=0.0 && N1 <= 90.0)
[Link]("Tangent of "+N1+"° = "+([Link](N1)));
else
[Link]("Invalid angle entered.");
break;
case 12:
[Link]("Enter two numbers.");
N1 = [Link]();
N2 = [Link]();
if(N1<N2)
[Link](N1+ " is smaller.");
else if(N1>N2)
13
[Link](N2+ " is smaller.");
else
[Link]("Both are equal.");
break;
case 13:
[Link]("Enter two numbers.");
N1 = [Link]();
N2 = [Link]();
if(N1<N2)
[Link](N2+ " is larger.");
else if(N1>N2)
[Link](N1+ " is larger.");
else
[Link]("Both are equal.");
14
}
break;
case 14:
[Link]("Enter a number.");
N1 =[Link]();
[Link]("Absolute value of "+N1+" = "+([Link](N1)));
break;
default:
[Link]("Invalid input entered.");
break;
[Link]();
[Link]("Press 0 to use the calculator again or any other number to exit.");
Exit = [Link]();
if(Exit!=0)
break; }
[Link](0);}}
15
SCREENSHOT
OUTPUT SCREEN
16
17
USER MANUAL
HOW TO START PROGRAM:
1. RIGHT CLICK ON CALCULATOR.
2. CLICK ON void main(String args[])
3. Follow the instructions and enter the required information as asked
by the program.
STEP BY STEP GUIDE
1. Choose the function which you wish to perform from the list.
2. Enter the number of the function which it corresponds to.
3. Enter a value or a set of values depending on the function.
18
4. You’ll get your desired result.
5. Press 0 to use the calculator again or enter any other number to exit.
BIBLIOGRAPHY
Computer Applications - A text book of Class X by Sumita Arora
The Complete Reference Java – Herbert Schildt
[Link]
[Link]
19
TEACHER’S REMARKS
1. Examiner I:
2. Examiner II:
3. Total Marks:
Principal’s Signature
20