CPP 1
CPP 1
A MICRO-PROJECT
This is to certify that the MICROPROJECT entitled “OBJECT ORIENTED PROGRAMMING” being
submitted here with for the award of DIPLOMA IN
ENGINEERING & TECHNOLOGY IN COMPUTER ENGINEERING of MAHARASHTRA STATE
BOARD OF TECHNICAL EDUCATION MAHARASHTA
guidance by Mrs.A.H.JADHAV
To the best of my knowledge and belif, the work embodied in this micro-project has
not formed earlier the basis for award of any degree or diploma of this or any other board of examining body.
DATE :
We, The under designed hereby declare that the project entitled “CREATE A BASIC
CALCULATOR” “ GOVERNMENT POLYTECHNIC AMBAD” during year 2022-2023, third
semester for partial fulfillment of the “ MICROPROJECT” requirement of “ OBJECT ORIENTED
PROGRAMMING” course under MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION, MUMBAI curriculum , under the guidance of Mrs. A.H.JADHAV.This is our
original work .
The empirical findings in this project are based on the collected data and are not copied from
anyothersources .
SUBMITTED BY
2. TYPES OF BASIC,SCIENTIFIC,GRAPHICS,MEMORY,FINANCIAL
CALCULATOR etc,CALCULATOR IMAGE.
BENEFITS OF USES OF CALCULATOR IN REGULAR AS WELL AS
CALCULATOR STUDENT LIFE.
4. ALGORITHM STEP BY STEP
THEROTICAL REPRESENT OF PROGRAM
INTRODUCTION:
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.
History of Calculator:
The importance of this helpful tool was known in the early times. At that time, early men use bones, pebbles and other
objects to tally the calculations.
But, it was very limited in nature. So, when the first mainframe computers came into existence. It was using vacuum tubes
and transistors. That leads to stepping stones to develop an electronic calculator.
Therefore, the first electronic calculator was launched by Casio computer company in 1957. followed by a series of models
with compact technology. Some leading manufactures opted for this technology to cover this new market. Like Canon,
Sony, Toshiba, Olivetti, etc.
Types of calculators:
Calculators have evolved over the last several decades. Today, there are a variety of calculators, from brands such as Casio
and Texas Instruments, available to serve different mathematical needs. Let's look at a few of them.
Basic calculators:
The most basic calculator is the four-function calculator, which can perform basic arithmetic such as addition, subtraction,
multiplication and division.
These are sometimes called pocket calculators or hand-held electronic calculators because they are small enough to fit in a
shirt pocket. They are also the least expensive calculator, costing around $5 or less.
Four-function calculators usually have a +, -, x and / sign to denote the operations and can produce decimal numbers.
Some also have a % button, which is used to calculate percentages.
Scientific calculators:
As its name suggests, the scientific calculator is designed for performing scientific calculations.
This type of calculator usually has more buttons than a standard calculator, as it needs to be able to perform trigonometric
functions, logarithms, sine/cosine and exponential operations.
The scientific calculator also usually has a larger display to view long equations and see more digits at a time.
Graphing calculators:
The next type of calculator is the graphing calculator. The graphing calculator is similar to the scientific calculator in that
it can perform many of the same operations.
However, the graphing calculator also can graph equations, for example, with more advanced mathematics like
trigonometry, on a coordinate plane. This is a valuable tool for visual learners or those studying mathematics that requires
a lot of graphing, such as calculus.
Financial calculators:
The last type of calculator we will discuss is the financial calculator. The financial calculator is an electronic device
designed for solving financial problems and uses paper tape to print calculations for hard-copy record-keeping.
This calculating machine can usually compute the present, future, rate of return and other critical financial concepts such
as return on investment. Financial calculators are essential for anyone studying finance or working in the financial
industry.
Memory Calculators:
Calculators also have the ability to store numbers into computer memory. Basic calculators usually store only one number
at a time; more specific types are able to store many numbers represented in variables. The variables can also be used for
constructing formulas. Some models have the ability to extend memory capacity to store more numbers; the extended
memory address is termed an array index.
Power source
Power sources of calculators are batteries, solar cells or mains electricity (for old models), turning on with a switch or
button. Some models even have no turn-off button but they provide some way to put off (for example, leaving no operation
for a moment, covering solar cell exposure, or closing their lid). Crank-powered calculators were also common in the early
computer era.
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.
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.
This program takes an operator and operands from the user.
The operator is stored in variable op and operands are stored in num1 and num2.....num n 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.
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.
A calculator is a portable device that helps to perform simple mathematical calculations in our daily lives such as addition,
subtraction, division, multiplication, etc. Some of the scientific calculators are used to perform complex calculation more
easily like square root, function, exponential operations, logarithm, trigonometric function and hyperbolic function, etc. In
this section, we will create calculator program in C++ using function and do-while loop.
Benefits of Calculator:
For complex calculations, the use of computers may be quite beneficial.
Students may save a lot of time by using a calculator in class to perform simple arithmetical calculations .
By doing so, they are able to focus their attention more on critical math topics rather than on the more fundamental tasks.
Students are required to master the fundamentals of operational arithmetic by the time they reach middle or high school.
Additionally, they must be capable of performing their own calculations. After all, they’d already mastered this skill in
their earlier sessions, when they were taught the exact same thing.
In other words, allowing students to use calculators in middle and high school is a win-win situation. As a result, the usage
of calculators in middle and high schools for calculations has a positive effect on students’ learning outcomes.
If you look back, calculators may appear to be overly easy, but when you examine them closely, you’ll discover that they
take some technical expertise to use effectively, especially when it comes to scientific calculators.
Therefore, middle school kids should be taught how to use a calculator in a variety of ways.
Calculators are more accurate than humans when it comes to doing computations.
Calculators may greatly enhance the precision of computations. Another consideration is the rate of change. The answer
can be found in a split second with the help of a calculator.
//PROGRAM:
#include <iostream.h>
#include <math.h>
class Calculator
{
int i, g[20], n;
public:
void result()
{
cout << " Enter The Size of an Elements :";
cin >> n;
cout << " Enter *" <<n<<"* Elements:";
float add()
{
int sum = 0;
for (i = 0; i < n; i++)
{
sum = sum + g[i];
}
return sum;
}
float sub()
{
float sub = g[0];
for (i = 0; i < n-1; i++)
{
sub = sub - g[i + 1];
}
return (sub);
}
float mul()
{
int mul = 1;
for (i = 0; i < n; i++)
{
return (mul);
}
float div()
{
if (g[0] == 0)
{
cout << " \ndivide by 0";
}
else
{
float div = g[0];
for (i = 0; i < n - 1; i++)
{
div = div / g[i + 1];
}
return div;
}
}
float square()
{
int m;
cout << "**Enter The Number For Square**: ";
cin >> m;
return (m * m);
}
float cube()
{
int m;
// Driver code
int main()
{
int ch;
Calculator c;
cout << "**Enter '1' for Addition of numbers**";
cout << "\n**Enter '2' for subtraction of numbers**";
cout << "\n**Enter '3'for multiplication of numbers**";
while(1)
{
cout << "\n**Enter Choice**: ";
cin >> ch;
switch (ch)
{
case 0:cout<<"Exit Successfully!! :";
break;
case 1:
c.result();
cout << "Result:: " << c.add() << endl;
break;
case 2:
c.result();
cout << "Result:: " << c.sub() << endl;
break;
case 3:
c.result();
c.result();
case 6:
int q;
q=c.cube();
cout<<"Result::" <<q<<endl;
break;
case 7:
c.result();
cout << "Result::" << c.mod() << endl;
break;
default:
cout << "!!!Enter Valid Choice !!!";
return 0;
}
OUTPUT:
Algorithm:
step1.start
step2.declare int ch;
step3.print statements.
Enter 1 to Add Numbers
Enter 2 to Substract Numbers
Enter 3 to Multiply Numbers
Enter 4 to Divide Numbers
enter 5 to square
enter 6 for cube
enter 7 for mod
Enter 0 To Exit
step 4.print statement
Enter the choice!!!!!!
Case 1: call to result,and enter the size of elments
And enter the elements .then call to add
For i=0 ,and repet the loop until i<n and then
Sum=sum+g[i] then print addition then break.
Case 2: call to result,and enter the size of elments
step 5.stop
CONCLUSION:
This program takes an operator and operands from the user.
The operator is stored in variable op and operands are stored in num1 and num2.....num n 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.
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.
REFERENCE:
1.https://www.techtarget.com/whatis/definition/calculator.
2.https://en.wikipedia.org/wiki/Mechanical_calculator.
3.https://www.ipl.org/essay/Importance-Of-Calculator-PJLLEGZT
4.OOP REFERENCE BOOK-MCGRAW HILL
THANK YOU!!!!!!