Cppfinal
Cppfinal
A MICRO-PROJECT ON
“CREATE A BASIC CALCULATOR”
CERTIFICATE
This is to certify that the Micro-project entitled “ OBJECT ORIENTED
PROGRAMMING”being submitted here with for the award of DIPLOMA IN ENGINEERING
& TECHNOLOGY in COMPUTER ENGINEERING of MAHARASHTRA STATE BOARD
& TECHNICAL EDUCATION (MSBTE) GOVER NMENT POLYTECNIC,AMBAD is
the result of Micro-project work completed by roll no 21,26,36,37under the supervision and
guidance of
MRS. A.H.JADHAV
It is to the best of my knowledge and belief that the work embodied in this Micro-project has not
formed earlier the basis for the award of any degree or diploma of this or any other Board or
examining body.
We, the undersigned hereby declare that the project entitled “CREATE A BASIC
CALCULATOR” is written and submitted by me to Government Polytechnic Ambad during
Year 2022-23, first Semester for partial fulfillment of the ‘Micro Project’ requirement of “
OBJECT ORIENTED PROGRAMMING” course under Maharashtra State Board of
Technical Education, Mumbai curriculum, under the guidance of Mrs.A . H . JADHAV is my
original work.
The empirical findings in this project are based on the collected data and are not copied from any
other sources.
We have great pleasure to express my immense gratitude towards a dynamic person and
my project guidance, Mrs. A. H. JADHAV Department of Computer Engeneering Government
Polytechnic, Ambad for giving me an opportunity to work on an interesting topic over one
semester. The work presented here could not have been accomplished without his most
competent and inspiring guidance, incessant encouragement, constructive criticism and constant
motivation during all phases of our group Micro-project work. I am highly indebted to him.
We are very much thankful to Prof. Banker sir, Head Department of Computer
Engeneering, all HODs of various departments and Prof. Dr. A.M.JINTURKAR Sir, The
Principal of Government Polytechnic, Ambad for his encouragement and providing me a
motivating environment and project facilities in the Institute to carry out experiments and
complete this Micro-project work.
We would like to extend my thanks to all our professors, staff members and all our
friends who extended their co-operation to complete the project.
We are indeed indebted to my parents and other family members for their
immense help at all levels with moral, social & financial support, care and support
throughout my studies without which my work would not have seen light of the day.
With warm regard Yours Sincerely,
INDEX
SRN TOPIC NAME SUBTOPIC NAME
O
1. INTRODUCTION WHAT IS CALCULATOR?
HISTORY OF CALCULATOR?
2. TYPES OF BASIC,SCIENTIFIC,GRAPHICS,MEMORY,FINANCIAL
CALCULATOR etc,CALCULATOR IMAGE.
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.
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.
Basic calculators:
The most basic calculator is the four-function calculator, which can perform basic
arithmetic such as addition, subtraction, multiplication and division.
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.
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.
#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();
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.
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!!!!!!