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:
- Cancel the input,
- Quit, and
- Mode selection.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started