Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Netbeans/ JAVA write this code: document every line. Two Classes! Create an arra

ID: 3669324 • Letter: N

Question

Netbeans/ JAVA write this code: document every line.

Two Classes!

Create an array of Strings, and using a stack, reverse the order of the Strings in the array. For example, the strings in the array might be Joe', Fred, "Mary". The reversed array would be "Mary Fred, Joe'. You should create a Stack class and a St class for this assignment, then use these classes in your software, Your stack should be a linked data structure, similar to a The main method should initialize an array of Strings-either with an explicit array declaration or by reading the data from afile. You should have at least five Strings in your array, but the software should work no matter how many Strings are in the array. Your stack class should maintain a stack pointer and the size of the stack, and should have methods to Push a new element onto a stack This method should put data onto the stack, which means it must first put the data in a stack element Pop an element off the stack and return the data in the element Print a list of the data in the stack. Return the current stack size.

Explanation / Answer

public class MyStack { private int maxSize; private char[] stackArray; private int top; public MyStack(int s) { maxSize = s; stackArray = new char[maxSize]; top = -1; } public void push(char j) { stackArray[++top] = j; } public char pop() { return stackArray[top--]; } public char peek() { return stackArray[top]; } public boolean isEmpty() { return (top == -1); } public boolean isFull() { return (top == maxSize - 1); } public static void main(String[] args) { MyStack theStack = new MyStack(10); String s="abcd"; for(int i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote