Question: Description Evaluating Mathematical Epressions: due 2 0 2 4 / 1 / 1 Mon ( at 1 1 : 5 9 pm ) A Mathematical
Description
Evaluating Mathematical Epressions: due Mon at :pm
A Mathematical epression is something like the following sin log in which there is a mixture of arithmetic expression, trigonometric, and logarithmic functions. Here is a list of those functions.
Basic arithmetic operators: ; r along with the unary negation operator ie
Unary scientific functions: sin cos tan log sart
Binary scientific functions: logba and You should use the corresponding math functions in to
implement them.
Remarks
Unary negation : note that must be interpreted as instead of The unary operator acts on
any double and turns its value negative
log stands for natural logarithm, ie with base e
Logba is ordanry logarithm with base b Use th Log function in to implement logba as logalogb
sqrt is square root.
stands for raising to the third power, which is equal to
Note that, according to our syntax, the curly braces are only used in logarithms subscript logba and power's superscript
The operators' priorities are listed as follows.
You do not need to check for invalid expressions like or invalid operations such as sqrt
priority operators lowest mediumunary
high
highest sin cos tan log log sqrt
If two operators have the same priority, they should be evaluated in from left to right.
Write a class Expression that holds the value of a Mathematical epression and it has at least two member functions input and eval in which the latter evaluates the expression. You may add members you like, as long as you keep all data members private or protected. We strongly suggest you use the getline function to read the whole expression as a string object remember to include Do not use cin str; as it will stop on whitespaces. Use getline cin str; instead to read the whole line in which str is a string object The main function is given as follows. Do not change main otherwise you may lose penalty points.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
