Question: Design and implement in C programming of a calculator for arithmetic expressions defined by the following grammar G = (N, T, P, S) where: N

Design and implement in C programming of a calculator for arithmetic expressions defined by the following grammar

G = (N, T, P, S) where:

N = {task, expr, term, factor, value, number, digit}

T = {=, +, -, *, ^, (, ), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

P = {task -> expr =

expr -> expr + term | expr term | -expr | term

term -> term * factor | factor

factor -> factor ^ value | value

value -> (expr) | number

number -> number digit | digit

digit -> 0 | 1 | 2 | 3 | 4| 5 | 6 | 7 |8 | 9

}

S = {task}

The symbols =, +, * are meant to denote end of expression, addition, and multiplication of numbers respectively. Moreover, - denotes both the binary operator of subtraction and the unary operator of taking the negative. The calculator should also provide the non-negative power of an expression which is represented by x ^ y and interpreted as x to the power of y.

The calculator will have two interaction guidance modes for input. One of which is to be Speech. These modes will give guidance to the user as to what input is expected next. For the input itself two input modes are to be provided, one of which is to be Speech.

The calculator will have two output modes. They are Speech and text. Switching between modes and simultaneous use of the two output modes should also be supplied. The output will be the input expression rendered in a form adequate for the respective mode and a statement of the calculated value. The spoken version would reflect the structure of the output and not just list the symbols. The interface for the calculator should include means for providing the user access to the following functions:

  1. Cancel the input,
  2. Quit, and
  3. Mode selection.

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!