Starting from:
$24.99

$18.99

Evaluating Arithmetic Expression Solution

The aim of this lab class is to provide you the experience with programming using stack.

 
 

TASKS:

 

A stack is collection that allows items to be inserted in a LIFO order.  A stack can either be implemented using a linked list or an array.  In this lab task, you are provided with a stack implementation using a linked list and you are required to use it in your program.

 

Your task is to write a program to evaluate an arithmetic expression in postfix notation using the stack class provided to you.  Your program should prompt the user to enter a filename that contains the postfix expression.  Proper validation should be done to the input read from the file to check whether the expression is well formed or not.  If the expression is not well formed then the user must re-enter a new filename.  Otherwise, evaluate the expression and display the result.  You may assume that the expression will only contain numbers (but no variables) and arithmetic operators +, –, *, and /.  Your program should also allow the user to evaluate other arithmetic expressions until the user wants to end the program.

 

Example program output:

 

 

 

Enter filename: expr.txt

 

Postfix expression is : 12  3 –  40 +

 

Result is 49

 

Do you wish to continue?  (Y/N) : N

More products