Question: implement a calculator that would pars evaluate an arbitrary expression that may 1) Rational numbers (e.g., 4.5669 or -3.5); 2) Parentheses '(' and ')'; 3)

implement a calculator that would pars evaluate an arbitrary expression that may

1) Rational numbers (e.g., 4.5669 or -3.5);

2) Parentheses '(' and ')';

3) Operators "+", "-", "*", "/", and "^". The latter operator is that of exponentiation, which,

has the highest precedence.Your code must handle rational exponentsincluding the negative ones. programmust1use a recursive-descent technique, as explained in class, based on the following grammar for expressions, as discussed in class:

'+' '-'

'*''/' '('')''.' ' 0', '1', '2' ... '9'

program must correctly handle all error conditions (it must never crash!). You may use all Java mathematical libraries available to you.and program should recognize:'='and process it by printing the value of the identifier. For example, you could writex = 20, which will result in your program displaying 20. Once an identifier has been assigned a value, it can be used in subsequent expressions (e.g., x+3). A subsequent assignment can change the value of the identifier.

You should store all identifiers in a hash table.

Step by Step Solution

3.42 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Implement a recursivedescent parser based on the given grammar for expressions Use a symbol table ha... View full answer

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 Programming Questions!