Write a Java implementation for the following problem. You can make use of which
ID: 3807913 • Letter: W
Question
Write a Java implementation for the following problem. You can make use of whichever of the ADTs Stack, Queue, and Deque that you need. Assume that these ADTs are already implemented, compiled and available in files Stack.class, Queue.class, Deque.class.
Input is read from the terminal (System.in). All input Strings are read and stored. The input String PRINT has a special meaning. Whenever a String that matches PRINT is read, the first stored string and the last 5 stored strings are printed. If there are not enough strings, the program should terminate as soon as it runs out of strings.
For example, if the input is:
1 2 3 4 5 6 7 8 PRINT 9 PRINT 10 11 12 13 PRINT
the output would be:
1 8 7 6 5 4 2 9 3