import java.util.*;
public class Homework {
public static void main(String args[]){
Stack<String> STACK = new Stack<String>();
String str = "";
Scanner sc = new Scanner(System.in);
while (!str.equals("q")) {
System.out.println("Input name or 'q' to stop:");
str = sc.next();
if (str.equals("q")) {
break;
}
STACK.push(str);
}
System.out.println("The stack is : ");
System.out.println(STACK);
System.out.println("Pop all elements from stack as follow :");
try {
while(true) {
str = STACK.pop();
System.out.println(str);
}
} catch (Exception e) {
}
}
}