Description of Program You are to write a program name eale.java that evaluates an infix expression entered by the user. The expression may contain the following tokens: (1) Integer constants (a series of decimal digits). (2) x (representing a value to be supplied later). (3) Binary operators (+,-,"./ and %). (4) Parentheses Spaces between tokens are allowed but not required. The program will convert the expression to postfix (RPN) form and display the converted expression. The program will repeatedly prompt the user for the value of x, displaying the value of the expression each time. When the user enters the letter q instead of a number, the program terminates. The following example illustrates the behavior of the program (user input is in bold and red): Porgram output is in bold and green. Enter infix expression: (x+1)* (x- 2) /4 Converted expression: x1+x2-4/ Enter value of x: 5 Answer to expression: 4 Enter value of x: 7 Answer to expression: 10 Enter value of x: q If the infix expression contains an error of any kind, the program must display the message Error in expression (with an optional explanation) and then terminate. The following examples illustrate various types of errors: Enter infix expression: 12+ Error in expression!! No operator between operands. Also last token must be an operand. Enter infix expression: 104 Error in expression!! Cannot accept floating point numbers. Enter infix expression: 1( +2) Error in expression!! No operator between operand and left parentheses. Enter infix expression: 5- (x- 2)) Error in expression!! No matching left parentheses for a right parentheses.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Description of Program
You are to write a program name cale.java that evaluates an infix expression entered by the user. The expression may contain the following tokens:
(1) Integer constants (a series of decimal digits).
(2) x (representing a value to be supplied later).
(3) Binary operators (+, -, *,/ and %).
(4) Parentheses
Spaces between tokens are allowed but not required. The program will convert the expression to postfix (RPN) form and display the converted expression. The program will repeatedly prompt the user for the value of x,
displaying the value of the expression each time. When the user enters the letter q instead of a number, the program terminates.
The following example illustrates the behavior of the program (user input is in bold and red):
Porgram output is in bold and green.
Enter infix expression: (x +1) * (x - 2) /4
Converted expression: x1+x 2-* 4/
Enter value of x: 5
Answer to expression: 4
Enter value of x: 7
Answer to expression: 10
Enter value of x: q
If the infix expression contains
a error of any kind, the program must display the message Error in expression (with an optional explanation) and then terminate. The following examples illustrate various types of errors:
Enter infix expression: 12+
Error in expression!! No operator between operands. Also last token must be an operand.
Enter infix expression: 10.4
Error in expression!! Cannot accept floating point numbers.
Enter infix expression: 1 ( +2)
Error in expression!! No operator between operand and left parentheses.
Enter infix expression: 5- (x - 2))
Error in expression!! No matching left parentheses for a right parentheses.
Transcribed Image Text:Description of Program You are to write a program name cale.java that evaluates an infix expression entered by the user. The expression may contain the following tokens: (1) Integer constants (a series of decimal digits). (2) x (representing a value to be supplied later). (3) Binary operators (+, -, *,/ and %). (4) Parentheses Spaces between tokens are allowed but not required. The program will convert the expression to postfix (RPN) form and display the converted expression. The program will repeatedly prompt the user for the value of x, displaying the value of the expression each time. When the user enters the letter q instead of a number, the program terminates. The following example illustrates the behavior of the program (user input is in bold and red): Porgram output is in bold and green. Enter infix expression: (x +1) * (x - 2) /4 Converted expression: x1+x 2-* 4/ Enter value of x: 5 Answer to expression: 4 Enter value of x: 7 Answer to expression: 10 Enter value of x: q If the infix expression contains a error of any kind, the program must display the message Error in expression (with an optional explanation) and then terminate. The following examples illustrate various types of errors: Enter infix expression: 12+ Error in expression!! No operator between operands. Also last token must be an operand. Enter infix expression: 10.4 Error in expression!! Cannot accept floating point numbers. Enter infix expression: 1 ( +2) Error in expression!! No operator between operand and left parentheses. Enter infix expression: 5- (x - 2)) Error in expression!! No matching left parentheses for a right parentheses.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY