Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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
Check Mark
Knowledge Booster
Background pattern image
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
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education