Question: Declare variable initialsDeque as a Deque of type Character. Assign initialsDeque with a LinkedList of type Character. Read three characters from input and add each
Declare variable initialsDeque as a Deque of type Character. Assign initialsDeque with a LinkedList of type Character. Read three characters from input and add each character to the head of initialsDeque, in the order read.
Ex: If the input is R N U then the output is:
U N R
SolveYour code goes here
import java.util.LinkedList;
import java.util.Deque;
import java.util.Scanner;
public class Initials
public static void mainString args
Scanner scnr new ScannerSystemin;
int i;
Any variable declarations go here
Queue codesQueue new LinkedList;
Your code goes here
for int i ; i ; i
char character scnrnextcharAt;
codesQueue.addcharacter;
Print each element of the deque from the head
for i ; i ; i
System.out.printinitialsDequeremoveFirst;
System.out.println;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
