Oops
Oops
This C++ microproject implements a basic calculator that performs arithmetic operations such as addition,
subtraction, multiplication, and division. This program takes an arithmetic operator (+, -, *, /) and two
operands from a user and performs the operation on those two operands depending upon the operator entered
by the user.
Implement a basic calculator that performs arithmetic operations. Understand and apply basic C++
programming concepts. Develop problem-solving skills using C++. Programming logic and problem-
solving, C++ syntax and semantics, code organization and readability, error handling and debugging, and
user interface design.
4. Proposed Methodology:
Phase 2: Implementation
6. Resources used:
Team Member:
1.Sonwane Neha Nagnath
2. Brief Description: -
Key Features:
Primary Aims:
Specific Aims:-
1. Implement basic arithmetic operations (+, -, *, /).
Learning Aims:
Educational Aims:
5. Material: -
To understand this example, you should have the knowledge of the following C++ programming
topics:
6.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.
Variables can be used in any equation and are substituted for their assigned value. Variables can be
inserted using the x button.
A computer can perform any operation that a calculator is capable of performing, but a calculator cannot
carry out the logical and highly complex problems. The reason behind this is that a computer can be
programmed to make decisions, but a calculator is not equipped with that technology.
7.Algorithum:-
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
7. code:
#include<iostream.h>
#include<conio.h>
#include<process.h>
Void main()
{
int ch;
float num1, num2, result;
cout << "Basic Calculator Program" << endl;
cout << "1. Addition" << endl;
cout << "2. Subtraction" << endl;
cout << "3. Multiplication" << endl;
cout << "4. Division" << endl;
cout << "5. Exit" << endl;
while{
cout << "Enter your choice (1-5): ";
cin >> choice;
if (choice == 5)
{
Break;
}
cout << "Enter first number: ";
cin >> num1;
cout << "Enter second number: ";
cin >> num2;
switch (ch)
{
case 1:
result = num1 + num2;
cout << "Result=”<<Result<<endl;
break;
case 2:
result = num1 - num2;
cout << "Result=”<<Result<<endl;
break;
case 3:
result = num1 * num2;
cout << "Result=”<<Result<<endl;
break;
case 4:
if (num2 != 0)
{
result = num1 / num2;
cout << "Result=”<<Result<<endl;
}
Else
{
cout << "Error! Division by zero is not allowed." << endl;
break;
}
default:
cout << "Invalid choice. Please choose again." << endl;
}
Getch();
}
8.OUTPUT:
9.Skill developed/learning outcomes of this micro project
Technical Skills:
Programming Concepts:
2. Problem-solving strategies
Soft Skills:
Real-World Applications:
1. Scientific Calculations:
The calculator can be used for scientific calculations, such as physics, engineering, or
mathematics problems.
2. Financial Calculations:
The calculator can be used for financial calculations, such as calculating interest rates,
investments, or loan payments.
3. Educational Tool:
The calculator can be used as an educational tool for teaching mathematics, algebra, or
programming concepts.
4. Embedded Systems:
The calculator can be integrated into embedded systems, such as calculators, watches, or
other handheld devices.
5. Gaming:
The calculator can be used in game development for calculations, such as physics, collision
detection, or scoring.