Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ANSWER IN JAVA THANKS Design and implement a class named Queue (Queue.java) for storing doubles. Like a stack, a queue holds elements. In a stack,

ANSWER IN JAVA THANKS

Design and implement a class named Queue (Queue.java) for storing doubles. Like a stack, a queue holds elements. In a stack, the elements are retrieved in a last-in, first-out (LIFO) fashion. In a queue, the elements are retrieved in a first-in, first-out fashion (FIFO). The class contains:

A double[] data field named elements that stores the double values in the queue.

A data field named size that stores the number of elements in the queue.

A constructor that creates a Queue object with default capacity 10

. The method enqueue(double v) that adds v into the queue

. The method dequeue() that removes and returns the element from the queue.

The method empty() that returns true if the queue is empty

. The method getSize() that returns the size of the queue.

A few notes:

Implement the class with the initial array size set to 10.

The array size will be doubled once the number of the elements exceeds the size

. After an element is removed from the beginning of the array, you need to shift all elements in the array one position to the left.

Write a testing Java application (QueueTest.java) that adds 10 numbers from 1 to 10 into the queue, then removes these numbers and displays them.

image text in transcribed

tail head Data 1 tail head Data2 Data 1 tail head Data3 Data2 Data1 tail head Data3 Data2 Data 1 1 tail After removing first element head Data3 Data2

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

Students also viewed these Databases questions

Question

What roles have these individuals played in your life?

Answered: 1 week ago