Question: C++ Operators + , - , * , / , and % are overloaded to perform the required operations with the desired objects. Create a

C++

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!