Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Variable seatNumbers is declared as a deque of type Integer. Three integers are read from input. Assign seatNumbers with a LinkedList of type Integer. Add

Variable seatNumbers is declared as a deque of type Integer. Three integers are read from input. Assign seatNumbers with a LinkedList of type Integer. Add each integer read from input to the tail of seatNumbers, in reverse order.
Ex: If the input is 37952, then the output is:
37 completed
9 completed
52 completed
import java.util.LinkedList;
import java.util.Deque;
import java.util.Scanner;
public class SeatNumbers {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
Deque seatNumbers;
int number1;
int number2;
int number3;
int i;
number1= scnr.nextInt();
number2= scnr.nextInt();
number3= scnr.nextInt();
/* Your code goes here */
// Print each element of the deque from the head
for (i =0; i <3; ++i){
System.out.println(seatNumbers.removeFirst()+" completed");
}
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions