Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Implement a recursivedescent parser based on the given grammar for expressions Use a symbol table ha... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions