Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions