Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

to which computer is the term "computer architecture" associated

Answered: 1 week ago

Question

Explain how to build high-performance service delivery teams.

Answered: 1 week ago

Question

Understand what a service-oriented culture is.

Answered: 1 week ago