## Description

Assignment:

Write a simple C++ calculator program. This program will consist of a single Calculator class

that keeps track of the running total. The total will be initialized to zero. The Calculator class

will consist of the following methods:

void add(double value);

void subtract(double value);

void multiply(double value);

void divide(double value);

double getTotal() const;

The program must offer a user interface, using cin and cout, to allow the user the ability to

manipulate the total. The user interface must look like the following:

*** Calculator ***

A: Add a value

S: Subtract a value

M: Multiply by a value

D: Divide by a value

T: Get the total

Q: Quit

Section:

You should write your program and break out the definitions and implementations into

main.cpp, Calculator.hpp, and Calculator.cpp.

1. [5 points] Create your main

2. [5 points] Create the user interface

a. Using cin and cout, create the user interface listed above.

b. The user input should be case insensitive

3. [30 points] The Calculator structure

a. Create a constructor

b. Create a destructor

c. Define each of the above listed functions

Execution Example:

Run 0)

*** Calculator ***

A: Add a value

S: Subtract a value

M: Multiply by a value

D: Divide by a value

T: Get the total

Q: Quit

Current Total: 0.0

Selection: A

*** Add selected ***

Value: 1.1

0.0 + 1.1 = 1.1

*******

Run 1)

*** Calculator ***

A: Add a value

S: Subtract a value

M: Multiply by a value

D: Divide by a value

T: Get the total

Q: Quit

Current Total: 1.1

Selection: S

*** Subtract selected ***

Value: 0.2

1.1 0.2 = 0.9

******

Run 2)

*** Calculator ***

A: Add a value

S: Subtract a value

M: Multiply by a value

D: Divide by a value

T: Get the total

Q: Quit

Current Total: 0.9

Selection: M

*** Multiply selected ***

Value: 2.2

0.9 * 2.2 = 1.98

******

Run 3)

*** Calculator ***

A: Add a value

S: Subtract a value

M: Multiply by a value

D: Divide by a value

T: Get the total

Q: Quit

Current Total: 1.98

Selection: d

*** Divide selected ***

Value: 2.2

1.98 / 2.2 = 0.9

******

Run 4)

*** Calculator ***

A: Add a value

S: Subtract a value

M: Multiply by a value

D: Divide by a value

T: Get the total

Q: Quit

Current Total: 0.9

Selection: T

*** Total selected ***

Total Value: 0.9

******

Run 5)

*** Calculator ***

A: Add a value

S: Subtract a value

M: Multiply by a value

D: Divide by a value

T: Get the total

Q: Quit

Current Total: 0.9

Selection: q

Thank you for using the calculator! Bye bye! Have a great day!

Extra Credit: [5 points]

1. Keep track of all operations and values

a. Instead of updating the user interface with the simple “total [operation] value =

new total”, add the complete set of mathematical operations and values

i. ((((0.0 + 1.1) 0.2) * 2.2) / 2.2) = 0.9