Question
#5 (use QUEUE ADT - 20 pts) (Chapter 4) // author files: ArrayBoundedQueue, QueueInterface, QueueOverflowException, QueueUnderflowException // INPUT: Take from the sorted list you created
#5 (use QUEUE ADT - 20 pts) (Chapter 4) // author files: ArrayBoundedQueue, QueueInterface, QueueOverflowException, QueueUnderflowException // INPUT: Take from the sorted list you created in #4 (so it will be alphabetical) and present it to the user; // ask user to identify the order in which they want to visit the travel destinations. // Save the order of each travel destination by enqueueing the NAME(not index) of each travel destination // into a QUEUE in the given order (of course, you MUST use the author's QUEUE code). // OUTPUT: PRINT the contents of the queue as you dequeue each element // so that what gets printed out are the travel destinations in the order the user wants to visit them. // ------------------------------------------------------------------------------------------------------
#4
Enter Location #1: London Enter Location #2: Paris Enter Location #3: Rome Enter Location #4: New York Enter Location #5: California Enter Location #6: Barcelona Content of the list Barcelona California London New York Paris Rome
//--------------------------------------------------------------------------- // ArrayBoundedQueue.java by Dale/Joyce/Weems Chapter 4 // // Implements QueueInterface with an array to hold the queue elements. // // Two constructors are provided: one that creates a queue of a default // capacity and one that allows the calling program to specify the capacity. //--------------------------------------------------------------------------- //package ch04.queues; publicclass ArrayBoundedQueue
//---------------------------------------------------------------------------- // QueueInterface.java by Dale/Joyce/Weems Chapter 4 // // Interface for a class that implements a queue of T. // A queue is a "first in, first out" structure. //---------------------------------------------------------------------------- //package ch04.queues; publicinterface QueueInterface
//package ch04.queues; publicclass QueueUnderflowExceptionextends RuntimeException { public QueueUnderflowException() { super(); } public QueueUnderflowException(String message) { super(message); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started