Question: It needs to be C++ PGM: Simple Calculator The purpose of this assignment is to practice programming simple program I/O, use of variables and arithmetic

It needs to be C++

PGM: Simple Calculator

The purpose of this assignment is to practice programming simple program I/O, use of variables and arithmetic expressions.

You are to build a calculator that accepts 2 double numbers and a string. These two numbers will be used in an arithmetic expression defined by the string. Both the expressions and result will be displayed to the screen.

NOTE: The input must be as follows: string number number This is a prefix expression

Output must repeat input the input in the following format:

Answer = arithmetic expression

Where

width of the field for the answer is 10 and it is right justified

= signs line up

Maximum decimal point length is 2

If the operator is not valid, output the statement Invalid expression

Arithmetic Expressions that must be defined are:

OPERATORS

Outputs the integer answer

+ addition

Int = number operator number

- subtraction

/ division

% modulus

* multiplication

COMPARATORS

Outputs string : True or False

== equality

String = number operator number

!= not equal

MATH FUNCTIONS

Outputs the integer or double result of the function call

^ first input raised to the power of the second

Int = pow(number, number)

< return minimum value

Int = min(number,number)

> return maximum value

int = max(number,number)

sqrt

Double = sqrt(number1)

If this is given, do not attempt to read the 2nd number

If this is processed in all, just ignore the second number

RUN ALL OPERATIONS

Returns the results for all operations listed

all

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!