PostfixEvalConsole - Simulation of console-I/O program...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Simulation of console-I/O program PostfixConsole, using ConsoleApplet as a basis. See the file for more information. */ * public class PostfixEvalConsole extends ConsoleApplet { p protected String getTitle() { return "Sample program \"PostfixEval\""; } protected void program() { /* This program evaluates postfix expressions entered by the user. The expressions can use non-negative real nubmers and the operators +, -, *, /, and ^ (where ^ represents exponentiation). Numbers must begin with a digit. That is, you have to say 0.7 rather than just .7. The value of an expression might be given as infinity or NaN. A stack is used to evaluate the expression. The stack is represented by an object of type NumberStack, as defined in For demonstration purposes, the stack operations are reported as they are performed. */ console.putln("This program can evaluate postfix expressions such as\n"); console.putln(" 2 2 +"); console.putln("or"); console.putln(" 7.3 89.2 + 9 1.83 * 2 + /\n"); console.putln("The operators +, -, *, /, and ^ can be used.\n\n");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2010 for the course CSC 115 taught by Professor Jackson during the Spring '09 term at University of Victoria.

Page1 / 3

PostfixEvalConsole - Simulation of console-I/O program...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online