Java @ Stacks Due date : July 14, 2013 9.00AM (EST) Objectives: To gain experience with stacks. Documentation: Explain the purpose of the program as detail as possible - 13%. Develop a solution for the problem and mention algorithms to be used -16% List data structures to be used in solution. - 5%. Give a description of how to use the program and expected input/output - 5% Explain the purpose of each class you develop in the program. - 5%. Programming: For each method, give the pre and post conditions and invariant, if any - 10% Program execution according to the requirements given 36% Naming of program as required 5% Print out of source code 5% Description of Program You are to write a program name calc.java that evaluates an infix expression entered by the user. The expression may contain the following tokens: (1)   Integer constants (a series of decimal digits). (2)x (representing a value to be supplied later). (4)   Binary operators (+, -, *, / and %). (5)   Parentheses   Spaces between tokens are allowed but not required. The program will convert the (user input) infix expression to postfix (RPN) form and display the converted expression on the screen.  The following example illustrates the behavior of the program (user input is in bold and red): Porgram output is in bold and green. Enter infix expression: (7 + x) * (8 – 2) / 4 + (x + 2) Converted expression: 7 x + 8 2 - * 4 / x 2 + + Enter a value for x: 5 The result is: 25  Enter a value for x: 8 The result is: 36  Enter a value for x: 3 The result is: 20  Enter a value for x: q ------>Any value that is not an integer - the program terminates When solving the postfix expression, you must prompt the user for an input value for x, solve the expression and return a result. You must use an operand stack to process the postfix expression. Display this result on the screen as well as the postfix expression as shown above. If the infix expression contains an error of any kind, the program must display...

  • 8 years ago
Java@Stacks A+ Tutorial use as guide
NOT RATED

Purchase the answer to view it

blurred-text
  • attachment
    javastacks.doc
  • attachment
    javastacks_2.txt