For the next problems write a client to test the following methods. Check out the lecture notes(attached) for thenecessary files(StackADT.java, LinkedStackClass.java, QueueADT.java, QueueClass.java,QueueException.java, QueueOverflowException.java, andQueueUnderflowException.java.)
1. (Method: printBackStack) Task: Display the contents of a stack in reverse order (top to bottom),leaving the stack unchanged.
SOLUTION:
public static void printBackStack(LinkedStackClass
}2. (Method: printStack) Task: Display the contents of a stack in direct order (bottom to top), leaving
the stack unchanged.
SOLUTION:
public static void printStack(LinkedStackClass
}3. (Method: getSecond) Task: Find the second item in a stack, leaving the stack unchanged.
SOLUTION:
public static Integer getSecond(LinkedStackClass
}
4. (Method: countItems) Task: Count the number of items in a stack, leaving the stack unchanged.SOLUTION:
public static int countItems(LinkedStackClass
}5. (Method: removeItem) Task: Delete every occurrence of a specified item from a stack, leaving the
order of the remaining items unchanged.
SOLUTION:
public static void removeItem(LinkedStackClass
}
6. (Method: reverseStack) Task: Reverse a stack, using a queue. The original stack is lost.SOLUTION:
public static void reverseStack(LinkedStackClass
}7. (Method: reverseQueue) Task: Reverse a queue, using a stack. The original queue is lost.
SOLUTION:
public static void reverseQueue(QueueClass
}8. (Method: printQueue) Task: Display the contents of a queue in direct order, leaving the queue
unchanged.
SOLUTION:
public static void printQueue(QueueClass
}
SAMPLE OUTPUT:
Enter integers (999 to stop): 25 10 15 10 20 37 10 59 21 10 27 20 4 2 10 53 47 37 5977 27 20 10 999The original stack printed in direct order (bottom to top) is:25 10 15 10 20 37 10 59 21 10 27 20 4 2 10 53 47 37 59 77 27 20 10The stack printed in reverse order (top to bottom) is:10 20 27 77 59 37 47 53 10 2 4 20 27 10 21 59 10 37 20 10 15 10 25The stack stores 23 items.The top is: 10The second item (below top) is: 20Enter value to be removed from stack: 10The stack after removing every occurrence of 10 is:25 15 20 37 59 21 27 20 4 2 53 47 37 59 77 27 20Reversed the stack. The new stack printed in direct order is:20 27 77 59 37 47 53 2 4 20 27 21 59 37 20 15 25The queue is:3 6 9 12 15 18 21 24 27 30The reversed queue is:30 27 24 21 18 15 12 9 6 3
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.