Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having trouble with the ExpressionTest.java. I'm not sure how to write code on how to take in command arguments from the terminal. We are

I'm having trouble with the ExpressionTest.java. I'm not sure how to write code on how to take in command arguments from the terminal.

image text in transcribed

We are used to writing arithmetic expressions with the operator between the two operands a +b or c / d If . we write a+b * c, however, we must apply precedence odders to avoid ambiguous evaluation. This type of expression is called infix expression. There are two other types of different but equivalent ways of writing expressions. Infix: X + Y: Operators are written in-between their operands. Infix expression needs extra information to make the order of evaluation of the operators clear: precedence and associativity. brackets ( ). For example, A(B+C)/D. Pestfix: X Y +: Operators are written after their operands. The above infix expression can be written using postfix notation a ABBC+D / Prefix: + X Y: Operators are written before their operands. The above infix expression can be written using prefix notation as /A+BCD You are to implement two class methods that can convert an infix expression to its equivalent postfix and evaluate the postfix expression. A temn will be an integer literal. The parameter to your methods will be an array of Strings and so is the retum value. Each element of the array can either be an integer literal or a binary operator +/ (where is the power operator, xy is xy ) You are to implement the class Expression which includes the algorithms comerrToPostfur and evaluatePostfix. They are class methods. Class mame: Expression Conversion of Infix to Postfix: Method name: String[] comvertToPostfix (String[] infixExpression) infexExpersion - each element is a token that can be an operator or an imteger literal. Operator can be +,,+,/, or . This method will comvert an infix to a postfix expression. Throw a RuvrimeErcoptionimesg) if ingixErpression is not well-formed or not an integer literal. Conversion of Infix to Postfix: Method name: int evaluatePostfix (Stringl posfixExpression) Throw RundimeErcoption/imsg) when posifixExceppriow is not well-formed or not an integer literal. You must implement your own generic Stack ADT for this project. What to test? Think of your own cases correct input, without parentheses or with matched parentheses; and incorrect input (with unmatched parentheses). Your program should catch the error with unmatched parentheses and when one of the operands is missing. Make sure that you deal with all error conditions, for example, pop/top on an empty stack. Write an application named ExpressionTest that will take an integer infix expression(s) from the command line. Using the Expression class to convert and output the equivalent postfix express, and the evaluation of the postfix expression. Project report: (PDF format) - Page 1: Cover page with your name, class, project, and due date - Page 2 to 3: - Section 1 (Project specification)s Your ADT description. Description of data structures used and a description of how you implement the ADT - Section 2 (Testing methodology) Description of how you test your ADT, refer to your testing output. Explain why your test cases are rigorous and complete. Demonstrate that you test each method. - Section 3 (Lessons learned): Any other information you wish to inclade. Turn in: 1. Project report PDF must be named report.pdf and included inside your zip submission

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

1. Select the job or jobs to be analyzed.

Answered: 1 week ago