Question: As instructed, Please modify the program (Add a new method) to the existing program import java.util. % / Function to check if stack is empty



import java.util. % / Function to check if stack is empty */ public boolcan isEmpty() i return lop=1; / Function to check if stack is full / public boolean isFull() \{ returntop=size1; / Function to get the size of the stack #/ public int getSize() return len: /* Function to check the top element of the stack / public int peek() \{ if (isEmpty()) throw new NoSuchElementException("Underflow Exception"); return arr[top]: / * Function to add an element to the stack */ public void push(int i) i default : System.out.println("Wrong Entry "); break; \begin{tabular}{l} /* display stack / \\ stk.display(); \\ System.out.println(" Do you want to continue (Type y or n) "); \\ ch = scan.next(),charAt (0); \\ ; while (ch== ' Ych==y); \\ \hline \end{tabular}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
