Oop Microproject PDF
Oop Microproject PDF
Presentor-
Gaurav Bangar
Jagdish Bangara
Tarang Jadhav
Purpose:-
1. Calculators are simply a tool students use to help solve problems. Since they eliminate tedious
computations and algebraic manipulations that discourage many students, calculators allow
more students to solve problems and appreciate the power and value of mathematics in the world
today. 2. Basic calculators can do only addition, subtraction, multiplication and division
mathematical calculations. However, more sophisticated calculators can handle exponential
operations, square roots, logarithms, trigonometric functions and hyperbolic functions. 3. It is
also a program on a computer that simulates a hand-held
calculator. Calculator programs let you perform simple math calculations .
Project Work (main Details)
Material:-
To understand this example, you should have the knowledge of the following C++
programming topics:
C++ switch case Statement
C++ break Statement
C++ continue Statement
Method:-
This program takes an operator and two operands from the user.The operator is stored in
variable op and two operands are stored in num1 and num2 .Respectively.Then, switch...case statement
is used for checking the operator entered by user.If user enters + then, statements for case: '+' is executed
and program is terminated.If user enters - then, statements for case: '-' is executed and program is
terminated..His program works similarly for the * and / operators. But, if the operator doesn't matches
any of the four character [+, -, * and /], the default statement is executed which displays error message
Theoretical Background:-
* What is a calculator?
A calculator is a device that performs arithmetic operations on numbers. Basic calculators can do only
addition, subtraction, multiplication and division mathematical calculations.However, more
sophisticated calculators can handle exponential operations, square roots, logarithms, trigonometric
functions and hyperbolic functions. Internally, some calculators perform all these functions by
repeated addition processes.The evolution of the calculator Most calculators these days require
electricity to operate or are battery-powered calculators. Calculators work by performing programmed
functions
based on numerical inputs.Before the electronic calculator (circa 1970), a more primitive calculator,
the slide rule, was commonly used. It consisted of a slat of wood called the slide that could be moved
in and out of a reinforced pair of slats. Both the slide and the outer pair of slats had calibrated
numerical
scales.
* What are the benefits of using calculators?
This technology allows students solve complicated problems quickly and in an efficient manner.
Additionally, it can reduce the problem to simpler tasks and allows the student to devote more time in
understanding the problem. Secondly, they are saved from monotonous calculations and the same
boring mundane procedure
Algorithm:-
Step 1: Start
Step 2: The operator is stored in variable op and two operands are stored in num1 and num2
respectively.
Step 3: Then, switch...case statement is used for checking the operator entered by user.
Step 4: If user enters + then, statements for case: '+' is executed and program is terminated.
Step 5: If user enters - then, statements for case: '-' is executed and program is terminated.
Step 6: This program works similarly for the * and / operators. But, if the operator doesn't matches
any of the four character
[ +, -, * and / ], the default statement is executed which displays error message.
Step 7: End
Coding:-
#include<iostream.h>
#include<conio.h>
class super{
char ch;int a,b;float val;
public:
super(){
cout<<"\nEnter Opration:";
cin>>ch;
cout<<"\nEnter two values";
cin>>a>>b;
}
void cal(){
if(ch =='+'){
val = a+b;
cout<<"\nAddition is:"<<val;
}
else if(ch=='-'){
val = a-b;
cout<<"\nSubtraction is:"<<val;
}
else if(ch =='/'){
val = a/b;
cout<<"\nDivision is:"<<val;
}
else if(ch == '*'){
val = a*b;
cout<<"\nMultiplication is:"<<val;
}
else if(ch == '%'){
val = a%b;
cout<<"\nModulous is:"<<val;
}
}
};
void main(){
clrscr();
char x;
do{
super s;
s.cal();
cout<<"\nEnter N to exit Enter Y to continue:\n";
cin>>(x);
}while(x != 'n');
getch();
}
Output:-
Conclusion
In this work we have developed a calculator for exact real number computation and performed a
theoretical analysis of the algorithms and experimented on their implementation.We began by
defining two representations of real’s in the range [-1, 1] using streams of digits. These
were then
extended to represent real numbers on the whole real line using a (mantissa, exponent) style
representation.
We showed how to convert between these representations, how to convert decimal numbers into a
signed binary representation, and how to convert a finite portion of the signed binary representation
back into decimal.Algorithms for the basic arithmetic operations were implemented for these
representations. A number of different techniques are used to obtain these algorithms, including
exploiting the relationship between the list operation `cons' and numerical average, using certain
identities, and analysing of the range of possible values of a stream starting with a given digit or
sequence of digits. We developed an algorithm for the direct multiplication of two streams of signed
binary digit. This is a more complex operation than the multiplication of dyadic digit streams, but
avoids the problem of dyadic digit swell which can be observed if the dyadic digit multiplication is
used to compute iterations of the logistic map, for example, and which can cripple performance.
We also developed an algorithm for the division of two signed binary numbers. This is significantly
more complicated than the familiar school long division method because in the school long division
method we know the whole denominator, whereas when dividing by a number with an infinite
representation this is not the case. Other approaches such as Fourier's cross-division method (a
description of which can be found in [30] p.159-164) which examine the denominator from right to
left are also unsuitable because they allow digits which have already been output to be `corrected'
later on, and hence each output digit depends on an
Resources/Reference
https://codescracker.com/cpp/program/cpp-program-make-calculator.htm
https://www.programiz.com/cpp-programming/examples/calculator-switch-case
https://www.exampleprogram.com/2020/05/how-to-write-simple-calculator-program.html