begintabularcccc hline Operator Operandi Operand2 Result hline b c z

Write in C++7. Write a client program that uses Stack abstract data to compile a simple arithmetic expression without parentheses. For example, the expression a + b * c - d should be compiled according to the following table:The table shows the order in which the operations are performed ( * , +, -) and operands for each operator. The result column gives the name of an identifier (working backward from z) chosen to hold each result. Assume that the operands are the letters a through m and the operators are (+,-,*,/). Your program should read each character and process it as follows: If the character is blank, ignore it. If the character is neither blank nor an operand nor an operator, display an error message and terminate the program. If it is an operand, push it onto the operand stack. If it is an operator, compare its precedence to that of the operator on top of the operator stack. If the current operator has higherprecedence than the one currently on top of the stack (or if the stack is empty), it should be pushed onto the operator stack. If the current operator has the same or lower precedence, the operator on top of the operator stack must be evaluated next. This is done by popping that operator off the operator stack along with a pair of operands from theoperand stack and writing a new line in the output table. The character selected to hold the result should then be pushed onto the operand stack. Next, the current operator should be compared to the new top of the operator stack. Continue to generate output lines until the top of the operator stack has lower precedence than the current operator or until it is empty. At this point, push the current operator onto the top of the stack and examine the next character in the data string. When the end of the string is reached, pop any remaining operator along with its operand pair just described. Remember to push the result character onto the operand stack after each table line is generated. Do problem 7 on pp 355-356. Do not worry about parenthesis, just use letters and +,-,/,*. Follow the guidelines the problem gives you on how to handle the operators and operands. Use single digit numbers instead of letters and show the result of the formula you use. Make it so I can enter a group of about 7 - 12 operators and operands in an expression. Print out the stack at every change, at the beginning and the end also.

Write in C++7. Write a client program that uses Stack abstract data to compile a simple arithmetic expression without parentheses. For example, the expression a + b * c – d should be compiled according to the following table:The table shows the order in which the operations are performed ( * , +, -) and operands for each operator. The result column gives the name of an identifier (working backward from z) chosen to hold each result. Assume that the operands are the letters a through m and the operators are (+,-,*,/). Your program should read each character and process it as follows: If the character is blank, ignore it. If the character is neither blank nor an operand nor an operator, display an error message and terminate the program. If it is an operand, push it onto the operand stack. If it is an operator, compare its precedence to that of the operator on top of the operator stack. If the current operator has higherprecedence than the one currently on top of the stack (or if the stack is empty), it should be pushed onto the operator stack. If the current operator has the same or lower precedence, the operator on top of the operator stack must be evaluated next. This is done by popping that operator off the operator stack along with a pair of operands from theoperand stack and writing a new line in the output table. The character selected to hold the result should then be pushed onto the operand stack. Next, the current operator should be compared to the new top of the operator stack. Continue to generate output lines until the top of the operator stack has lower precedence than the current operator or until it is empty. At this point, push the current operator onto the top of the stack and examine the next character in the data string. When the end of the string is reached, pop any remaining operator along with its operand pair just described. Remember to push the result character onto the operand stack after each table line is generated. Do problem 7 on pp 355-356. Do not worry about parenthesis, just use letters and +,-,/,*. Follow the guidelines the problem gives you on how to handle the operators and operands. Use single digit numbers instead of letters and show the result of the formula you use. Make it so I can enter a group of about 7 – 12 operators and operands in an expression. Print out the stack at every change, at the beginning and the end also.


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (5 ratings) 5 out of 5 people found this solution helpful.