Question
Operators + , - , * , / , and % are overloaded to perform the required operations with the desired objects. Create a class
Operators + , - , * , / , and % are overloaded to perform the required operations with the desired objects.
Create a class called calculator which will include the following functions:
- Default constructor
- Constructor with a parameter
- Operator overloading using friend functions for the following operators:
- +
- *
- /
- %
- Sqrt method that will find the square root of a number.
- Display method that will display the numbers, the operation and the result.
Write a menu-driven C++ program that uses operator overloading to perform the following tasks on numbers.
/*SAMPLE RUN OF ABOVE PROGRAM :
Calculator options:
+ add
- subtract
* multiply
/ divide
% remainder
s square root
e exit calculator
Enter your selection ==> +
Enter number --> 12
Enter number --> 34
answer --> 46
Calculator options:
+ add
- subtract
* multiply
/ divide
% remainder
s square root
e exit calculator
Enter your selection ==> %
Enter number --> 45
Enter number --> 7
answer --> 3
Calculator options:
+ add
- subtract
* multiply
/ divide
% remainder
s square root
e exit calculator
Enter your selection ==> e
*/
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started