Complete the PostFixExpression class that is partially defined below.public class PostFixExpression {private List<object> L;public PostFixExpression (string s) { … }private void Analyzer (string s) { … }private void Convert ( ) { … }public float? Evaluate ( ) { … }public override string ToString( ) { … }}1. The constructor creates but does not initialize a List L of objects. It then calls private methodsAnalyzer and Convert to perform the initialization of L. (2 marks)2. The method Analyzer processes the given string character by character, separates out its integerand operator components, and inserts them into list L. If a character is not a digit or an operator,then an ArgumentException is thrown with an appropriate message. (9 marks)3. The method Convert transforms list L into a postfix expression usinga. a local instance of an operator (character) stack andb. the rules of precedence given earlier.No error checking is performed except for balanced parentheses. If parentheses are not balanced,then an ArgumentException is thrown with an appropriate message. (9 marks)Page 3 of 64. The method Evaluate returns the result of the current postfix expression using a local instance ofan operand (floating point) stack. If the postfix expression is syntactically incorrect, then the erroris identified, and null is returned. Syntax errors include:a. Too few or too many operandsb. Too few or too many operatorsA syntax error throws an ArgumentException with an appropriate message. A runtime check fordivision by 0 also throws an ArgumentException with an appropriate message. (8 marks)5. The method ToString returns the string representation of the postfix expression. (2 marks)The main program is straightforward. It reads in a string s from the console and then declares, definesand evaluates an instance of PostFixExpression based on string s. The main program also catches anyexceptions that are raised elsewhere.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Complete the PostFixExpression class that is partially defined below.
public class PostFixExpression {
private List<object> L;
public PostFixExpression (string s) { … }
private void Analyzer (string s) { … }
private void Convert ( ) { … }
public float? Evaluate ( ) { … }
public override string ToString( ) { … }
}
1. The constructor creates but does not initialize a List L of objects. It then calls private methods
Analyzer and Convert to perform the initialization of L. (2 marks)
2. The method Analyzer processes the given string character by character, separates out its integer
and operator components, and inserts them into list L. If a character is not a digit or an operator,
then an ArgumentException is thrown with an appropriate message. (9 marks)
3. The method Convert transforms list L into a postfix expression using
a. a local instance of an operator (character) stack and
b. the rules of precedence given earlier.
No error checking is performed except for balanced parentheses. If parentheses are not balanced,
then an ArgumentException is thrown with an appropriate message. (9 marks)
Page 3 of 6
4. The method Evaluate returns the result of the current postfix expression using a local instance of
an operand (floating point) stack. If the postfix expression is syntactically incorrect, then the error
is identified, and null is returned. Syntax errors include:
a. Too few or too many operands
b. Too few or too many operators
A syntax error throws an ArgumentException with an appropriate message. A runtime check for
division by 0 also throws an ArgumentException with an appropriate message. (8 marks)
5. The method ToString returns the string representation of the postfix expression. (2 marks)
The main program is straightforward. It reads in a string s from the console and then declares, defines
and evaluates an instance of PostFixExpression based on string s. The main program also catches any
exceptions that are raised elsewhere. 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education