In Java, please write the COMPLETE code for the prompt in the following TWO pict
ID: 3864725 • Letter: I
Question
In Java, please write the COMPLETE code for the prompt in the following TWO pictures.
-Please write the program as simply as possible.
-Please read and follow the prompt closely
-THE STEP-BY-STEP INPUT/OUTPUT OF THE PROGRAM IS LOCATED IN THE FIRST PICTURE (1 - 9)! Once again, READ THE PICTURES! This is what I mean by "Read and follow the prompt closely"! Everything you need to know is in the pictures! Please don't ask me to update the question if you haven't read the pictures!
-Your program should run.
-Your program MUST implement and use STACK class methods. That means there must be peek(), push(), pop(), and remove() methods that interact with the stack.
-We have not learned hashmap yet, so please DONT use hashmap.
-DO NOT USE COLLECTIONS.
-MUST use a separate class to represent Objects for Stack.
-MUST search through Stack at some point.
All of the details of the program can be found in the following pictures. PLEASE DON'T WASTE MY QUESTION ALLOWANCE WITH PARTIAL CODE OR CODE THAT DOES NOT FOLLOW THESE DIRECTIONS. This is the 6th time posting this question and I'm running out!
THANK YOU!
Explanation / Answer
public class StackReviseDemo { public static void main(String[] args) { LinkedList newStack = new LinkedList(); newStack.push(10); newStack.push(1); newStack.push(50); newStack.push(20); newStack.push(90); display(newStack); newStack.pop(); newStack.pop(); newStack.pop(); newStack.pop(); display(newStack); } private static void display(LinkedList newStack) { boolean first = true; LinkedList reversedStack = new LinkedList(newStack); Collections.reverse(reversedStack); for (Integer integer : reversedStack) { if (first) first = false; else System.out.print(" "); System.out.print(integer); } System.out.println(); } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.