Challenge

Scientific Calculator

About the Scientific Calculator

A Scientific calculator is a type of electronic calculator, usually but not always handheld, designed to calculate problems in science, engineering, and mathematics. They have completely replaced slide rules in traditional applications, and are widely used in both education and professional settings.

About the Project

This Project is of a Scientific Calculator which can be used for some of the calculations as similar to the scientific calculator.This is made by using and following the concepts of Object Oriented Programming also called as OOPs.

OOPS
Object Orriented Programming is a method Used for designing a program using classes and object. OOPs is also called the core of java . OOPs organize a program around object and well - defined interface. This Implies Software development and maintainence by using some of concepts :

1. Object 2. Class 3. Abstarction 4. Inheritance 5. Polymorphism 6. Encapculation

SCIENTIFIC CALCULATOR USING OOPS :
In below zip file the whole code for scientific Calculator ,digit convertor , and SIP calculator is written. In this report we are going to see hoe this calculator works using OOPS concept .

OBJECT : Objects are always callde as instance of an object .Object are created from class in java or any other languages. Objects are those that have state and behaviour. For Example : In calculator I used diffrent objects of class ScientificCalculator i.e.. add,subtraction , multiplication, division.....etc .

ScientificCalculator calci = new ScientificCalculator();

In the above code 'calci' is an Object of class ScientificCalculator,this object 'calci' uses for following behaviour. calci.Addition(),calci.Subtraction(),calci.Multiplication(),calci.Division(),etc..

CLASSES : A class is a user defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type .

ABSTRACTION : Abstraction is a process which displays only the information needed and hides the unnecessary information . We can apply that the main purpose of abstraction is data hiding . Abstraction means selecting data from a large number of data to show the info needed , which helps in reducing programming complexcity and efforts .

ABSTRACTION : Abstraction is a process which dicplays only the information needed and hides the unnecessary information . We can ay that the main purpose of abstraction is data hiding . Abstraction means selecting data from a large number of data to show the info needed , which helps in reducing programming complexcity and efforts . For Example :

//abstract parent class

Abstract class animal {

//abstract method

public abstract void sound ( ) ;

}

Public class lion extends animal {

Public void sound ( ) {

System.out.println (“ roar “ );

}

public Static void main ( String args [ ] ) {

animal obj = new lion ( );

obj. sound ();

}

}

INHERITANCE : Inheritance is a method in which one object acquires/inherits another object’s properties, and inheritance also supports hierarchical classification. The idea behind this is that we can create new classes built on existing classes, i.e., when you inherit from an existing class, we can reuse methods and fields of the parent class. Inheritance represents the parent-child relationship.
For Example, a Eagle is a part of the classification of Carnivorous bird , which is part of class aves, which is under that class of Birds. We use hierarchical classification, i.e., top-down classification.

Class a {

}

Class b extends class a {

}

POLYMORPHISM : Polymorphism refers to many forms, or it is a process that performs a single action in different ways. It occurs when we have many classes related to each other by inheritance. Polymorphism is of two different types, i.e., compile-time polymorphism and runtime polymorphism. One of the examples in Compile time polymorphism is that when we overload a static method in java. Run time polymorphism is also called a dynamic method dispatch is a method in which a call to an overridden method is resolved at run time rather than compile time.

ENCAPSULATION : Encapsulation is one of the concepts in OOPs concepts; it is the process that binds together the data and code into a single unit and keeps both from being safe from outside interference and misuse. In this process, the data is hidden from other classes and can be accessed only through the current class’s methods. Hence, it is also known as data hiding. Encapsulation acts as a protective wrapper that prevents the code and data from being accessed by outsiders. These are controlled through a well-defined interface.


Encapsulation is achieved by declaring the variables as private and providing public setter and getter methods to modify and view the variable values.

WORKING OF SCIENTIFIC CALCULATOR :
At first we are creating diffrent class for calculation purpose , such as we have made ScientificCalculator . In class ScientificCalculator we have created diffrent behaviours/parts of calculation i.e.. addition , subtraction , multiplication,division .etc.


We have also used interface serilaization by iimplimenting in class scicalculate to store value which can't be seen without Deserilisation .
Then in main class we first asked for which type of calculation will they do, for every option their is different loop . These loop will be closed only when we select OFF option .


We have a seperate option for History which is been stored in seperate file named CalculationsHistory.txt . Whenever we want to check History just refresh the project.

If we want to recall any number that we have calculated we can recall using recall option and also stor option is there if we want to store calculated value or any new number then we can do using this stor option.

This Calculator can can convert the decimal to binary number coversion by using object d2b made from class DigitConversion.

EXPLAINATION OF CODE IN PROJECT:

  • The code is a scientific calculator.
  • It has functions for addition, subtraction, multiplication, division, power, square root and natural logarithmic value.
  • The code also has functions for calculating the nth root of a number and the inverse sine function.
  • The program starts by declaring two variables: "a" is an integer variable that will hold the first input from the user; "b" is an integer variable that will hold the second input from the user.
  • Next it declares three integers: Addition(), Subtraction() and Multiplication().
  • These are methods in which you can enter 2 numbers to calculate their sum or difference or product respectively.
  • Division() calculates how many times one number divides into another number (the quotient).
  • Power() calculates how many times one number raised to another power (the exponent).
  • SquareRoot() calculates what's called a square root of a given number; this means taking any positive whole number x and finding its cube root y such that x^3 = y^2 + y - 1 .
  • LogarithmicValue() takes any positive whole number x as input and returns its logarithm base 10 equivalent z .
  • NaturalLog() takes any positive whole
  • The code is an example of a scientific calculator.
  • It has five methods that calculate the mathematical value of various mathematical operations.
  • The code is a program that calculates the sine, cosine, tangent and inverse tangent of an input number.
  • The code starts by declaring variables for the sin, cos, tan and atan functions.
  • Next it declares two methods: one to calculate the sine of a number and another to calculate the inverse sine of a number.
  • These are then used in other methods to calculate other trigonometric functions such as Cos(), InverseCos(), Tangent() and InverseTan().
  • The first method is called Sin(x) which takes an input value x as its parameter.
  • It returns the result of calculating sin(x).
  • This method uses sc (the System class) which is declared in line 1 below this line: System sc = new System(); This variable stores information about how many decimal places should be displayed when displaying numbers on screen or printing them out with printf().
  • If you want more than 2 decimal places displayed then use "sc" instead of "Math".
  • The next statement creates an instance of Math called m1 using new keyword followed by parentheses containing arguments for constructor function name ("Math") followed by argument list ("new").
  • Line 3 sets up m1's precision so that it can handle values greater than
  • The code will calculate the sine, cosine, tangent and inverse tangent of a given number.
  • The code will also print out the values for each function as well as a message.
  • The first if statement asks the user what kind of value they want to store as an int, so that it can be used later on in the program.
  • If they enter 1, then the next line asks them for an input number that will be stored in sc.nextInt().
  • This is done because there are two different types of values being asked about: one being an integer (1) and another being a floating point number (2).
  • The code attempts to calculate the sum of two variables and store it in a third variable.
  • The code starts by asking the user which type of value they want to store, 1-int or 2-Double.
  • If the user enters 1, then the nextInt() function will be called on sc.
  • The nextInt() function will return an int and input will be set equal to that int.
  • If the user enters 2, then doubleInput will be called on sc.nextDouble().
  • The nextDouble() function will return a double and input will be set equal to that double.
  • After this point, both variables are stored in stor(), with input being stored as 0 and store being stored as whatever was calculated from those
  • The code starts by declaring variables for the input and store.
  • The input is an int variable, while the store is a double variable.
  • Next, it declares two methods: recall() and calculate().
  • Recall() takes in an int as its parameter and calculates the value of a + input.
  • Calculate(), on the other hand, takes in a double as its parameter and calculates the value of a + input.
  • The main method starts by asking which kind of calculation do you want to recall/Recover 1-int or 2-Double?
  • It then asks for an integer n that will be used to determine what type of calculation should be performed next (1 if you want to recover an int or 2 if you want to recover a double).
  • If n equals 1, then it calls recall() with sc.nextInt(); otherwise, it calls calculate() with sc.nextDouble().
  • After calling either one of these methods, they both call their respective stored values before returning them back out again so that they can be displayed on screen later on in this same method's code block using System.out println("Here is your Stored Value : ")
  • The code is a program that asks the user to enter an int or double variable.
  • The code then calculates and stores the value of what was entered.
  • Then, it asks the user to enter another variable for calculation.
  • It then calculates and stores the value of what was entered, and displays both values on screen.
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.