Question: in C++ design, implement, and test an application to evaluate expressions with type double operands - add exponentiation operator (use a caret ^ as the
in C++ design, implement, and test an application to evaluate expressions with type double operands - add exponentiation operator (use a caret ^ as the exponentiation operator symbol) and modulus operator (%) evaluation. Thoroughly test your code.
Note: exponentiation associates right to left.
int main()
{
Tree
char again = 'y';
cout << " Use a Binary Tree for Preorder Expression Evaluation ";
do {
cout << " Enter expression terminated by an equal sign, e.g.: - * 6.2 3.1 5.8 = ";
buildExprTree(e);
cout << " The value of the expression is " << eval(e);
cout << " Another (y/n): ";
cin >> again;
} while (again == 'Y' || again == 'y');
cout << " -- Done -- ";
return 0;
}
/* Sample output: is
Use a Binary Tree for Preorder Expression Evaluation
Enter expression terminated by an equal sign, e.g.: - * 6.2 3.1 5.8 =
* - 8.1 5.3 / + 4.44 2.78 1.3 =
operator: *
operator: -
operand: 8.1
operand: 5.3
operator: /
operator: +
operand: 4.44
operand: 2.78
operand: 1.3
The value of the expression is 15.5508
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
