This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Programming Assignment #2 CMPSC 20, Spring 2008 Date assigned: April 18, 2008 In this assignment you will develop a linked data structure that stores a single-variable algebraic expression. You are supposed to develop functionality to encode and decode a given expression to and from a linked data structure. 1 Programming Assignment #2 - Due on May 15, 2008 Create a public class called Expression that implements the following public methods 1- A constructor Expression(String s) builds the linked structure from the input string s 2- A method String infixString() : returns an infix string representation of the stored Expression 3- A method String prefixString() : returns a prefix string representation of the stored Expression 4- A method String postfixString() : returns a postfix string representation of the stored Expression- The constructor input string s is an infix representation of the expression. For example: "5 - x + 2 * x * (x^2 + 5) - x^4 / (x - 3)" , this same string should be also the returned value of the method infixString().- Your constructor must check the following conditions for the input string: 1- The parentheses nesting is valid, for example, 5 + (2 * x)...
View Full Document
- Spring '08