CCSU Fall 1998 Project 3 Posting Date: October 26, 1998 Due Date: November 11, 1998 Relevant Demos: None. Instead, see infix.java on pages 138 ff. of the text. This project comes in only one part. It covers material on stacks and translation from infix to postfix notation. Background: The purpose of this project is to give you practice with stacks, and practice with an important application of stacks, translation from infix to postfix notation. This, translation from infix to postfix, is closely related to parsing, which is the first step in compiler design. However, it is simple enough so second semester students can master it. Description: Write a java Applet to convert Boolean expressions from infix to postfix. Use & for AND, use | for OR, and use ! for NOT. The priority of operations is ! has priority over & and | & has priority over | | has lowest priority There will be two Boolean constants, 0 for false and 1 for true. Use single upper case letters for variables. For simplicity, there will be no spaces in valid expressions, and all variable names will be exactly one letter long. Examples: infix postfix !A&B A!B& !(A&B) AB&! A&B|C AB&C| A&(B|C) ABC|& A&1 A1& A|0 A0| You will want to adapt the algorithm presented in table 4.10, page 131, of the text, and the corresponding java code given in the infix.java program on page 133. Your Applet panel will contain two Labels, two TextFields, and one Button. It will look something like this: ------------------------------------ | | | -------------------- | | Infix | | | | -------------------- | | | | -------------------- | | Postfix | | | | -------------------- | | | | --------- | | | Convert | | | --------- | | | ------------------------------------ The user should be able to type a valid Boolean infix expression into the Infix TextField, click the Convert Button, and see the corresponding postfix expression appear in the Postfix TextField. If the user types in an invalid expression and clicks the Convert Button, a message such as "Invalid Boolean Expression should appear in the Postfix box. The text describes how to find most errors -- something ends up left on the stack when you finish converting. You may need to add a symbol checker method to check that the current symbol is a valid one. Valid symbols are upper case letters, the digits 0 and 1, the operators &, | and !, and left and right parentheses. If you wish, you may add a Label or two saying things like "Infix to Postfix Converter" and "for Boolean Expressions". Students who need help with Applets will find copious examples in the demos on the Spring 1998 CS 151 Web page, accessible from the Web page for this course via the Java Resources page. General Instructions: (1) Hand in a FOLDER containing (1) a printed copy of the text of the RPN.java Applet, and (2) a 3.5" floppy disk with the .java and .class files for your class. The folder should have a pocket, as described in project 1. (2) Your .java and .class files MUST be named and RPN.java, RPN.class. There are no data and output files. (3) Your program must begin with a remark box, as described in project 1. Under files, list none. (4) Each method in your program must begin with a remark box as described in project 1. (5) Your program MAY NOT use a depreciated api, as described in project 1.