Question: Exercise 1: Create a Stack and Perform basic operations like push, pop and peek. Setting up the Environment: Create a new Project on Netbeans. Give

 Exercise 1: Create a Stack and Perform basic operations like push,

Exercise 1: Create a Stack and Perform basic operations like push, pop and peek. Setting up the Environment: Create a new Project on Netbeans. Give the project name Lab4 Class Lab4.java Create two String stacks Stackl and Stack2. Push the following items to Stackl. o Jack O Queen o King o Ace 010 Print Stackl & Stack2. Perform two operations to add items from Stackl to Stack2. Print Stackl & Stack2 items. Perform pop() from Stackl, and print the popped item & Stackl. Print the item at the top of Stackl & Stack2 without removing it. Exercise 2: Implement a method, which takes a Stack of strings and a string to search for. The method should return the position of the searched item in the stack or -1 if it doesn't exist. Note: The search method should not destroy the current stack. public static int findPosition(StackS, String x) your code : return position: 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!