Project
Thisconsole based project is created by-
first I create an interface Calc.with the file n"ameCalc.java is created.then, wecreat base Calculate with the file name "Calculate.java " which conatain all the methods for calculation.After the basic class we create to classes "BasicCalculator and ScientificCalculator and SIPCalculator" are created.This classes call the method defined in the base classCalculate. Class BasicCalculator conatains an instance of Class Calculate.where as ScientificCalculator inherits Class Calculate and then uses its methods.After creation of all the above classes . a main class UseCalculator is created. which provides creates instance of class BasicCalculator or class ScientificCalculator based on the option selected by user.
*The Calc Interface
Interface Calc provides the structure of method which can be used in any code.It contains the two methods.
1.doCalculation() : here in this method we declare a method for providing methods for calculation.
2.getResult():here we are declaring a method for extracting the result of the calculation.
*The Calculate class
Class calculate contains the real logic of calculators. It conatains the methods for calculation of various mathematical operations .
class calculator uses interfaces by implementing interface Calc. The class contains following methods-
Here we i use concept of "polymerisation" for creating three constructor with same name but with different arguments.
i>Calculate()-here i create Default constructor for the class without any arguments.
ii>Calculate(Double dbNumber,char coperation)--here I create constuctor containing two arguments.This constuctor is used for ScientificCalculator calculations.
iii> Calculate(double num1,char cOperator, double num2)--create constuctor using three arguments.This constructor is used for BasicCalculator calculations.
Then I override methods doCalculation() and getResult().where doCalculation prints the calculation based on numbers and operators inputed by user.override the docalcultion function of Calc interface.
and getResult prints the result of calculation.
v>checkDouble()--it Ckecks if Basic and Scientific calculation is performed.
*The Basiccalculator class
This class extends the Calculate class.
Class basic claculator calculates basic functions like addition,substraction,multiplication,dividsion of two numbers.The class is provide option to user to give first number then to give operation and then to give secind number by Scanner class.
This class create creates an object of Class calculate by calling its constuctor by passing thre areguments.After the creation of object of Class Calculate doCalculation() method and GetResult() method which present the resy=ult of calculation to the user.
It uses while loop to provide an option to the user performs multiple calculations till the user does not indicate the end of procees by input n
*The ScientificCalculator class--
this class performs operation like sin,cos,tan, inverse,power,squareroot etc.
The calss provide option to user to enter the operation and then to enter number by using Scanner Class.Class ScientificCalculator inherits Class Calculate to use its methods.The calss passes the user enetred values to Class calculate by calling its Constructor with two arguments. The class called doCalculation() method which is followed by ny getResult9) method which show the result to user.
This class aslo uses while loop to provide an option to the user performs multiple calculations till the user does not indicate the end of procees by input n
*The SipCalculator Class
** The Usecalculator Class
This class provides three options to the user 1)Basic 2)Scientific 3) Sip . Based on the option enterd by the user.the clss creates an instance of class BasicCalculator for Basic or an instance of class ScientificCalculator for Scientific calculations or Class SIP for sip calculation.
To craete this console based project I used features like interface,iinheriting interface,looping and i/o classes.