import java.util.Scanner; public class UsingJAVA { public static class Stack { //we are defining the stack class private int maximumSize; //its the size of the array private int[] structure; //this is the array in which the contents are stored private int top; public Stack(int M) //this is the constructor { maximumSize = M; //The size of the array is of the user's choice structure = new int[maximumSize]; // we are making an array top = -1; // top is declared -1 because we need to access the 0th postion at first insertion } public void push(int j) //function to put values into stack. { structure[++top] = j; //the value of top pointer is increased and value is inserted } public int pop() //to take data out of the stack { return structure[top--]; //decrement takes the top to the element below the top element } public boolean isEmpty() //standard function to check whether the stack is empty or not { return (top == -1); } public boolean isFull() //standard function to check if the stack is full? { return (top == maximumSize - 1); } public static void main(String[] args) { int x; System.out.println("What should be the size of the stack?"); Scanner inputScanner= new Scanner(System.in); x=inputScanner.nextInt(); Stack Workstack = new Stack(x); //the object of the stack class is made System.out.println("Please enter the values you want to insert into stack"); for(int j=0; j