Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help with a Data Structures lab in Java. I have most of it done, but having it match the rubric completely is proving to be
Help with a Data Structures lab in Java. I have most of it done, but having it match the rubric completely is proving to be difficult. All work should be done within the evaluate method I believe. Any help would be appreciated!
^Above is the main method.^Above js the toString method.
Create a new Java project called "Lab1. You should use code from chapter 3 source code to recreate the user interaction for accepting the infix expression as found in PostFixTester. Complete the implementation of the ArrayStack class presented in chapter 3 removing the "jsjf" package references. Specifically, complete the implementation of the isEmpty ( ), size() and tostring() methods. (discussed in lecture). Output of toString() will be in the same form as generated by Arrays.toString() and ArrayList.toString() and only contain only valid data elements. Your completed project will contain the following 5 source code files: - InfixGenerator.java (adapted from chap03\PostfixEvaluator.java) - InfixGenTester.java (adapted from chap03\PostfixTester.java) - EmptyCollectionException.java (copied from chap03\jsjflexceptions) - ArrayStack.java (with the 3 incomplete methods fully implemented, copied from chap03\jsjf) - StackADT.java (copied from chap03\jsjf) Use your completed ArrayStack to implement a postfix to infix translator in a class called "InfixGenerator". The assignment project will contain ArrayStack.java, EmptyCollectionException.java and StackADT.java. (from the source code provided) InfixGenerator class will contain the functionality of the translation and be invoked from main(). Make sure that your InfixGenerator class is using your ArrayStack class and not the Java Collections Stack class. In addition you will create a java class called InfixGenTester.java that contains the main() method and your utilization of the translation exposed by InfixGenerator. Use as much as you find useful from the PostfixEvaluator/PostfixTester class examples from chapter 3. Hint: Much like the PostFix evaluator pushes the Integer result of a calculation back onto the stack, push the String result of the operands/operator string concatenation onto the stack. The use of parentheses for each translation is encouraged to strictly maintain order of operations. To test your implementation of the ArrayStack.toString() method your program will output the contents of the stack after every "token" of the postfix expression is processed. Each time a data item is pushed the stack will display and each time an operator is encountered the stack will be displayed suffixed with the operator. The last line of output will be the end result of the conversion. (see example below). System.out.print()/println() may only be used in main(). Example session: Enter a valid post-fix expression one token at a time with a space between each token (e.g. 54+ 321+ ) Each token must be an integer or an operator (+,,,/) 74315+/ The expression evaluates as: [7] [7,4] [7,4,3] [7,4,3] [7,(43)] [7,(43),1] [7,(43),1,5] [7,(43),1,5]+ [7,(43),(1+5)] [7,(43),(1+5)]/ [7,((43)/(1+5))] [7,((43)/(1+5))] [7((43)/(1+5))] 7((43)/(1+5)) Evaluate another expression [Y/N] ? y Enter a valid post-fix expression one token at a time with a space between each token (e.g. 54+ 321+)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started