import java.util.*;
class Stack
{
int st[]= new int[10];
int maxSize=10;
int top=-1;
void push(int ele)
{
if(top==maxSize)
{
System.out.println("the stack is full");
}
else
{
st[++top]=ele;
}
}
int pop()
{
int ele=0;
if(top==-1)
System.out.println("the stack is empty");
else{
ele=st[top--];
}
return ele;
}
void display()
{
for(int i=0; i<=top; i++)
System.out.println(""+st[i]);
}
}
class checkMain
{
public static void main(String args[])
{
Stack s1=new Stack();
int ch=1,choice=0,ele=0;;
Scanner sc= new Scanner(System.in);
do{
System.out.println("enter choices 1:push 2:pop 3:display");
choice=sc.nextInt();
if(choice==1)
{
System.out.println("enter the element to push");
ele=sc.nextInt();
s1.push(ele);
}
if(choice==2)
{
ele=s1.pop();
System.out.println("popped element is"+ele);
}
if(choice==3)
{
s1.display();
}
System.out.println("Do you want to continue(1-Yes 0-No");
ch=sc.nextInt();
}
while(ch==1);
}
}