Question: Page number 1 CS 2 1 0 - Yoo Project 1 2 0 2 4 PROJECT DESCRIPTION: Implement calculator to evaluate arithmetic equations with numbers
Page number
CS Yoo Project
PROJECT DESCRIPTION:
Implement calculator to evaluate arithmetic equations with numbers single digit integers in the range of
to and four operators using Python.
DUE: : PM on September Sunday
Your project will be divided into three parts:
Part : Classfunctions for Postfix Calculator
Part : Classfunctions to convert Infix notation to Postfix notation
Part : Driver program integrating Part and Part to run several test cases
The final program should include functionsclass to evaluate a regular postfix expression using stack
Part functionclass to convert the infix expression to postfix expression Part and a driver
program to run the test cases Part
Part : Postfix Calculator
Please create functionsclass to take the postfix expression as input and evaluate it You may review the
attached exercise to understand and practice infix and postfix notation.
There are many ways to implement Postfix Calculator. However, your program should use your own
Stack class implemented as an extendable array. Do NOT use the STL Stack. Below are some functions
to handle Stack. Feel free to add more functions such as helper functions to handle Stack:
push x; push a new element x on the stack.
pop ; removes the top element from the stack.
size ; returns the number of elements in the stack.
isFull ; checks if the stack is full.
isEmpty ; checks for the empty stack.
top ; returns the element at the top of the stack without removing it from the stack.
Pseudocode to evaluate the postfix expression:
for each token in the expression do;
read a symbol
If its a number,
push it onto the stack
Otherwise # ie it is an operator
Pop the stack and store the number as the right operand
Pop the stack and store the number as the left operand
Compute the value of left operand OPERATOR right operand
Push the result onto the stack
End for
The final result will be the last value on the stack.
Pop the stack and return the result.
Check for the errors:
# If the stack has more than one element left and there are no more operators, or
# the stack has one element left and there is at least one operator then signal an error.
Part : Converting Arithmetic Expression from Infix to Postfix Notation
In part you created postfix calculator which may work well but the postfix notation is not very human
friendly. Please create functionsclass to convert the infix expression as postfix notation as a solution.
When a user enters the arithmetic expression in infix notation, your function will change it into postfix
notation which will be an input to postfix calculator to generate an answer.
Please review the pseudocode below:
initialize Stack and Output arrays as empty
while there is symbol to be read in input string
read the symbol
case:
operand output it
push it on the stack.
pop operators from the stack to the output
until a is popped; do not output either of the parentheses.
operator pop higher or equalprecedence operators from the stack
to the output;
stop before popping a lowerprecedence operator or a
Push the operator on the stack.
end case
end while
pop the remaining operators from the stack to the output
Follow the steps in the pseudocode for an input of A B C D
Input: A B C D
Input Symbol Stack Content Output
A nil A
A
A
B A B
A B
C A B C
A B C
A B C
D A B C D
nil A B C D
Output: A B C D
Part : Driver Program Projectpy
Create a driver program to integrate classes generated from part and part and run test cases. Your final
program will interact with the users to evaluate regular arithmetic expression to generate the answer as
shown below as an example:
Enter an arithmetic expression:
Continue? YN
Y
Enter an arithmetic expression:
Continue? YN
N
Bye
GRADING:
Your program will be graded not only on meeting the stated requirements of the project, but also on
design quality and programming style coding standard Program should be defectfree no error A late
project may be accepted with a penalty of per day.
Collaboration on project or copying from Internet is not allowed and is considered as cheating. You are
required to observe the University and Departmental policies on academic honesty. Any requests for
special consideration relating to late projects must be discussed with and approved by the instructor in
advance.
SUBMISSION:
The project submission should in a zip file format including the files:
All source codes Projectpy including classesfunctions created
Snapshot of the output after running the test expression cases below:
o
o
o
Use a name convention of CSProjectyourLastName
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
