Computer Project Grade 10 Calculator

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

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.

2.JAVA is an object oriented programming which makes the whole program


modular, flexible and extensible.

3.JAVA 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.

4.UsingJAVA 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 java.util 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

importjava.util.*;

importjava.math.*;

class Calculator

public static double N1,N2,Res;

public static intCh,Exit=0;

public static Scanner in = new Scanner(System.in);

public static void main()

while(Exit==0)

System.out.print('\f');

System.out.println("This is a calculator. The various functions listed below can be performed:");

System.out.println("--------------------------------------------------------------------------");

System.out.println();

System.out.println("1.Addition 8.Rounding a number off to the nearest integer");

System.out.println("2.Subtraction 9.Finding the sine of an angle ");

System.out.println("3.Multiplication 10.Finding the cosine of an angle ");

System.out.println("4.Division 11.Finding the tangent of an angle ");

8
System.out.println("5.Squaring a number 12.Finding the smaller of two numbers");

System.out.println("6.Raising a number to a power 13.Finding the larger of two numbers ");

System.out.println("7.Finding a number's square root 14.Finding the absolute value of a number ");

System.out.println();

System.out.println("Enter your choice by pressing the number it corresponds to");

Ch = in.nextInt();

switch(Ch)

case 1:

System.out.println("Enter two numbers");

N1 = in.nextDouble();

N2 = in.nextDouble();

System.out.println("Sum of "+N1+" and "+N2+" = "+(N1+N2));

break;

case 2:

System.out.println("Enter the number from which you wish to subtract.");

N1 = in.nextDouble();

System.out.println("Enter the number you wish to subtract from "+N1);

N2 = in.nextDouble();

System.out.println("Difference between "+N1+" and "+N2+" = "+(N1-N2));

break;

9
case 3:

System.out.println("Enter 2 numbers.");

N1 = in.nextDouble();

N2 = in.nextDouble();

System.out.println("Product of "+N1+" and "+N2+" = "+(N1*N2));

break;

case 4:

System.out.println("Enter the number which you wish to divide.");

N1 = in.nextDouble();

System.out.println("Enter the number you wish to divide "+N1+" with.");

N2 = in.nextDouble();

System.out.println("Quotient: "+(N1/N2));

System.out.println("Quotient: "+(N1%N2));

break;

case 5:

System.out.println("Enter a number.");

N1 = in.nextDouble();

System.out.println("Square of N1 = "+(N1*N1));

break;

10
case 6:

System.out.println("Enter the base first and then the index.");

N1 = in.nextDouble();

N2 = in.nextDouble();

System.out.println(N1+" to the power of "+N2+" = "+(Math.pow(N1,N2)));

break;

case 7:

System.out.println("Enter a number.");

N1 = in.nextDouble();

System.out.println("Square root of "+N1+" = "+ (Math.sqrt(N1)));

break;

case 8:

System.out.println("Enter a number.");

N1 = in.nextDouble();

System.out.println(N1+" can be rounded off to "+ (Math.rint(N1)));

break;

case 9:

System.out.println("Enter an angle.");

11
N1 = in.nextDouble();

if(N1>=0.0 && N1 <= 90.0)

System.out.println("Sine of "+N1+"° = "+(Math.sin(N1)));

else

System.out.println("Invalid angle entered.");

break;

case 10:

System.out.println("Enter an angle.");

N1 = in.nextDouble();

if(N1>=0.0 && N1 <= 90.0)

System.out.println("Cosine of "+N1+"° = "+(Math.cos(N1)));

else

System.out.println("Invalid angle entered.");

break;

12
case 11:

System.out.println("Enter an angle.");

N1 = in.nextDouble();

if(N1>=0.0 && N1 <= 90.0)

System.out.println("Tangent of "+N1+"° = "+(Math.tan(N1)));

else

System.out.println("Invalid angle entered.");

break;

case 12:

System.out.println("Enter two numbers.");

N1 = in.nextDouble();

N2 = in.nextDouble();

if(N1<N2)

System.out.println(N1+ " is smaller.");

else if(N1>N2)

13
System.out.println(N2+ " is smaller.");

else

System.out.println("Both are equal.");

break;

case 13:

System.out.println("Enter two numbers.");

N1 = in.nextDouble();

N2 = in.nextDouble();

if(N1<N2)

System.out.println(N2+ " is larger.");

else if(N1>N2)

System.out.println(N1+ " is larger.");

else

System.out.println("Both are equal.");

14
}

break;

case 14:

System.out.println("Enter a number.");

N1 =in.nextDouble();

System.out.println("Absolute value of "+N1+" = "+(Math.abs(N1)));

break;

default:

System.out.println("Invalid input entered.");

break;

System.out.println();

System.out.println("Press 0 to use the calculator again or any other number to exit.");

Exit = in.nextInt();

if(Exit!=0)

break; }

System.exit(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

 https://www.geeksforgeeks.org/java/

 https://www.javatpoint.com/java-programs

19
TEACHER’S REMARKS

1. Examiner I:

2. Examiner II:

3. Total Marks:

Principal’s Signature

20

You might also like