Question: 1. Specification Design, write and test a program that accepts an arithmetic expression of unsigned integers in postfix notation in which the tokens are separated

1. Specification Design, write and test a program that accepts an arithmetic expression of unsigned integers in postfix notation in which the tokens are separated by spaces and builds and processes the arithmetic expression tree that represents that expression. The main class will be P2GUI. It should create a Swing based GUI shown below:

1. Specification Design, write and test a program that accepts an arithmetic

The GUI must be generated by code that you write. You may not use a drag-and-drop GUI generator. Pressing the Construct Tree button should cause the following: (i) the arithmetic expression tree that represents the entered postfix expression will be constructed, (ii) using that tree, the corresponding fully parenthesized infix expression should be generated and displayed in the GUI and finally (iii) a file should be generated that contains the 3-address format instructions corresponding to the arithmetic expression. These topics, including relevant classes for implementing and processing an expression tree, are discussed in the week 4 reading Binary Trees, Expression Trees, BST (AVL) trees, and B-Trees section II Expression Trees. The above example should produce the following output file containing the 3-address instructions: Add R0 5 9 Sub R1 3 R0 Mul R2 2 3 Div R3 R1 R2 It is not necessary to reuse registers within an expression as shown in the above mentioned reading and you can assume there are as many available registers as needed. Each new expression should, however, begin using registers starting at R0. You may assume that the expression is syntactically correct with regard to the order of operators and operands, but you should check for invalid tokens, such as characters that are not valid operators or operands such as 2a, which are not valid integers. If an invalid token is detected, a checked custom exception InvalidTokenException should be thrown and caught by the main class and an appropriate error message should be displayed in an JOptionPane. Below is an example:

expression of unsigned integers in postfix notation in which the tokens are

Your program should compile without errors. The Google recommended Java style guide (https://google.github.io/styleguide/javaguide.html) should be used to format and document your code. Specifically, the following style guide attributes should be addressed: header comments include filename, author, date and brief purpose of the program; In-line comments used to describe major functionality of the code; the meaning and the role of variables and constants are indicated as code comments; meaningful variable names and prompts applied; class names are written in UpperCamelCase; variable names are written in lowerCamelCase; constant names are in written in All Capitals; braces use K&R style. In addition the following design constraints should be followed: declare all instance variables private; avoid the duplication of code.

Three Adddress Generator Enter Postfix Expression 359+ 23* onstruct Tree Infix Expression ((3-(5+9))/(2*3))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!