Instructions The statements that may be entered are as follows: ::= ";" | ::= "cell" "=" ::= ::= "" | ("+" | "-") ::= ::= "" | ("*" | "/") ::= "number" | "cell" | "(" ")" | "prod" "(" ")" ::= "cell" ".." "cell" ::= "eval" | "print" | "dump" | "done" "cell" is a single letter followed by an integer (both in legal range): e.g. a4. "number" is an unsigned integer. To get -5 use 0-5. There is no unary minus. Sorry. example commands A6 = 5; // The letter names the column and the integer the row. B8 = A6 + 1; // also elaborate expressions with operators +-*/ and parens. A9 = sum(B1..C4); // also prod(range) where range == cell..cell The accept button accepts commands as you enter them, but does not evaluate the sheet. The clear button clears the command input area. The evaluate button evaluates the entire sheet. Commands are entered into the command field at the bottom of the frame that initially says Welcome. This text field may be cleared at any time with the Clear button. Enter a command into the command box and then push the Accept Button. The sheet will not be updated until you push the Evaluate button. Note that all commands are terminated by semicolons. Only 26 columns may be used (letters a-z). IMPORTANT NOTE: A recursive command (e.g. A0=A0+1) is illegal. There is no check for it in this program however. Your program will eventually crash if you try it. It is also possible to write mutually recursive sets of commands. These are just as illegal. Exercises: (In approximate increasing order of difficulty ) Add a unary minus. Use ~ for this operator, not -. ~5 means minus 5. Add the modulo operator to the language. Use % for this operator. 12 % 5 should yield 2. Give the program a prettier interface. Add an additional range function. Choose a good one. Add an exponentiation operator. Use ^ for this operator. 2^5 should yield 32. The precidence level of ^ should be higher than that of * and /, but lower than parens. Note that if you permit 2^5^3, that it should group from the right as 2^(5^3). The included operators all group from the left within precidence levels. Add a logic operator similar to the C++ conditional expression operator ?:. To the left of the ? you need a comparison like a4<3. To the right you need two expressions separated by the colon. What improvements can you make that will increase the total code size by no more than one page? Explanation of classes Class Spreadsheet is derived from applet. It is a view-controller class. It does not have any functionality beyond managing the views and the buttons/fields. Class SpreadsheetModel is the actual spreadsheet. It uses a class SpreadsheetCell for the cells in the rectangular array. Class SemanticRecord is used to hold information in spreadsheet programs. A Semantic record is either a value or a cell reference. Each cell may represent a simple value or a spreadsheet program. A spreadsheet program is a vector of pairs of integers and semantic records. It represents an expression written in postfix. In other words. expression a+b is represented in the program as " a b +" The operands are either constants or other cells. A spreadsheet program is evaluated by pushing operands onto an evaluation stack and popping them when an operator needs to be evaluated. The result of the operation is then pushed back on the stack. A range of cells is represented internally by listing all of its members. Thus programs that use ranges may be quite long. They are maintained in fully expanded form.