Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Goals Answer the following questions. Points applicable for each of the questions are mentioned alongside the question 1. Show the stack and output(postfix) string

Assignment Goals Answer the following questions. Points applicable for each of the questions are mentioned alongside the question 1. Show the stack and output(postfix) string states as you read each character from the following 3 input(infix) strings and convert to output(postfix) strings [20 pts] (a) (a/b)*(c+d) (b) a-(b +c)*d Note: Use the attached Excel spreadsheet and update as shown in the sample below Keep in mind the rules for converting infix to postfix Sample for converting (a + b) * c infix string to postfix string ab+c* Infix Input String (a + b) * c Character Read from Input(infix) String Stack State Output postfix string ( ( Blank a ( a + ( + a b (+ ab ) Stack Empty ab+ * * ab+ c * ab+c No more character to read Stack Empty ab+c*

March 4, 2023 p 3 2. Refer to algorithm in pseudo code, as documented in Section 5.18 of the Textbook and discussed in class, to evaluate each of the 3 postfix expressions, given the variable values shown below [15 pts] a = 7 b = 3 c = 4 d = 4 e = 10 (a) ab+c*d (b) ab*ca/de*+ (c) acb^d+ 3. Refer to algorithm convertToPostfix, as in Segment 5.16 of the textbook and as discussed in class presentation. Define a class MyExpressionConverter and use this algorithm to create the following static method for this class: (a) ConvertToPostfix (String infixString) [20 pts] - This method takes 1 String argument that is an infix expression - Return a postfix version of this infixString (b) Test this ConvertToPostfix method, by converting the following infix expression strings to postfix[15 pts] (i) a * b / ( c - d ) (ii) ( a - b * c ) / ( d * e * f + g ) (iii) a / b * ( c + ( d - e ) ) 4. In this question you will create your Vector-based Stack class [30 pts] (a) make a class called MyVectorStack that is a vector-based implementation of the ADT stack.

March 4, 2023 p 4 (b) Create an interface called StackInterface that specifies a stack of objects, along the lines of Listing 5-1 in textbook. Your interface definition should support generic type T (c) Your stack class should implement the above interface (d) In addition to the methods as outlined in Stack interface, make a void method remove(n) that removes n entries from the top of the stack (e) For this method: (i) Write Javadoc (ii) Write java code for this method (iii) Be sure to handle cases where the stack may not contain n entries or when the stack is empty Note: A meaningful message must be provided to the client should operation(s) on the stack fail for any reason Extra Credit [5 points] Define a custom Exception class to handle errors encountered while performing operations on the stack 5. Create the following classes for a vector-based implementation of the ADT stack [25 points] (a) MyLinkedStack class This class represents a linked implementation of the ADT Stack. Make sure you implement all stack methods as defined in the StackInterface. Keep in mind that being a linked implementation, you will need to create an inner class Node, similar to the one created in the linked implementation of ADT Bag (b) LinkedStackTest class This class will contain the main method that will do the following:

March 4, 2023 p 5 - Create objects of type GymEquipment. Be aware, since you cannot create instances of GymEquipment class, you will be using its subclasses to create GymEquipment objects - Show examples to test functionality of each of the methods defined in the MyLinkedStack class - Display stack content that will show each object (with its details) that was

Im stuck how to code it and make it run perfectly

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

How has Globalization affected global business todays world

Answered: 1 week ago