Docsity

CST 230 Spring 2006 HW #2: Stack Interface for Infix Evaluator, Assignments of Data Structures and Algorithms

Toggle sidebar
bg1
Razdan 2/17/2008
CST 230 Spring 2006
Homework #2 (10/1/07)
Weight 3%
Due 10/25/07 (in class)
Instructions: This is a programming home work.
This is a homework in which you will implement a simple interface for stacks. You
can use an array or linked list (yours or Java’s collection class). You will implement
the stack(s) in such way to implement an infix expression evaluator.
An example of an infix expression is as follows:
{3*(4 + 2) * (6 – 2) * ( 2 + (7 + 3)/2) }
All four operators i.e. * / + and – are allowed.
All three parenthesis are allowed i.e. {}, (), [].
All input will be legal.
Your program should run in an infinite loop until the character “e” or “E” or “Esc”
is pressed. Your program should ask for an expression. Upon hitting the “return”
key, you should evaluate the expression and out the result.
Three test cases will be run each worth 1 point.

Partial preview of the text

Download CST 230 Spring 2006 HW #2: Stack Interface for Infix Evaluator and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Razdan 2/17/

CST 230 Spring 2006

Homework #2 (10/1/07)

Weight 3%

Due 10/25/07 (in class)

Instructions: This is a programming home work.

This is a homework in which you will implement a simple interface for stacks. You can use an array or linked list (yours or Java’s collection class). You will implement the stack(s) in such way to implement an infix expression evaluator.

An example of an infix expression is as follows: {3*(4 + 2) * (6 – 2) * ( 2 + (7 + 3)/2) }

All four operators i.e. * / + and – are allowed. All three parenthesis are allowed i.e. {}, (), []. All input will be legal.

Your program should run in an infinite loop until the character “e” or “E” or “Esc” is pressed. Your program should ask for an expression. Upon hitting the “return” key, you should evaluate the expression and out the result.

Three test cases will be run each worth 1 point.