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
/* Solve_Your code goes here */
import java.util.LinkedList;
import java.util.Deque;
import java.util.Scanner;
public class Initials {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
int i;
/* Any variable declarations go here */
Queue codesQueue = new LinkedList<>();
/* Your code goes here */
for (int i =0; i <3; i++){
char character = scnr.next().charAt(0);
codesQueue.add(character);
}
// Print each element of the deque from the head
for (i =0; i <3; ++i){
System.out.print(initialsDeque.removeFirst()+"");
}
System.out.println();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!