Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language- C++ Problem Description Create a class named Calculator with a data member named mValue which has a default value of 0.0 (double). This Calculator

Language- C++

image text in transcribed

Problem Description Create a class named Calculator with a data member named mValue which has a default value of 0.0 (double). This Calculator class should have the functions to add, subtract, multiply, and divide into mvalue. For example, using the add function with an argument of 10.0 would cause mvalue to be added 10.0 into (0.0 + 10.0). If then, the subtract function with an argument of 5.0 is called, the new value in mvalue would then be 5.0 (10.0 - 5.0). The same logic applies to multiplication and division. Your Calculator class should also have functions to get the number stored in mValue and a way to clear its value back to 0.0. After your class is complete, write code to let the user use this calculator as follows: 1. The user is asked whether they want to add, subtract, multiply, divide, show stored value, clear stored value, or exit the program a. You can use 0 to add, 1 to subtract, 2 to multiply, etc. b. You can use chars as well ('a' to add, 's' to subtract, etc.) 2. If the user selects to add, subtract, multiply, or divide, the user is asked to enter the number they wish to add, subtract, multiply, or divide with. Apply the operation and show the user the new value stored in the calculator. 3. If the user selects to show stored value, simply show the value 4. If the user selects to clear stored value, clear the calculator value back to 0.0 and show the new value 5. If the user selects exit the program, exit the program 6. If the user selects anything else, inform the user they have selected an incorrect option and to select again Hard Requirements Your Calculator class should have its data members private. It should also have the 6 specified functions listed in the Problem Description (no other functions are required). The user should continue to use the operation until the user selects to exit

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions