Question: Question #2-Implementing Stacks (30pts) You are writing a Java Program to implement a stack. A stack is a Last-In-First-Out (LIFO) data structure. You will write

 Question #2-Implementing Stacks (30pts) You are writing a Java Program to

Question #2-Implementing Stacks (30pts) You are writing a Java Program to implement a stack. A stack is a Last-In-First-Out (LIFO) data structure. You will write the push0 method to add an element to stack, pop0 method to remove an element from stack and peek0 method to return the value of the top element in the stack Follow the following steps: a) Create a class called MyStack0 b) Create the appropriate instance variables. You will need an array to implement the stack and variables to keep track index of the stack. You will also need to create a variable for the size to set the size of the array c) A default constructor to create and initialize the array and assign the variables to the defaults values. d) The class should contain the following methods - pop0 to delete an item from the stack - push0 to add an element to the stack - peek0 to check the top element of the stack - is Empty0 to check if the stack is empty - isFullO to check if the stack is full - getsize0 to return the size of the stack - display0 to display the status of the stack e) Create a StackApp class to try your MyStack class. Display the following menu operations: Push, Pop, Peek, Empty, Full, and Size

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!