Question: In this project, you will be designing and implementing a Java program that uses the Queue data structure. Your program should be able to demonstrate

In this project, you will be designing and implementing a Java program that uses the Queue
data structure. Your program should be able to demonstrate the functionality of the queue
structure and show how it can be used in real-world scenarios.
Instructions:
1. Design a Java program that uses the Queue data structure. Your program should include
the Queue code which is included with my notes and we discussed in class.
2. Your program should include at least three different operations for the Queue data
structure.
3. Your program should also include error handling for unexpected scenarios.
4. You can choose any real-world scenario to demonstrate the use of this data structure.
Some examples could be a restaurant order system, a shopping cart, or a playlist
manager.
5. Write documentation that explains the purpose of your program and how it works.
Requirements:
1. Your program should be well-structured and easy to read.
2. Your code should be properly commented to explain the functionality of each method.
3. Your documentation should include the purpose of your program, how it works, and
how to run it. The documentation should also describe the use of any tools that helped
you with the design, including AI tools.
4. Your program should be free of errors and able to handle all possible scenarios.
5. You should be able to answer any question regarding your project and your code.
Grading: Your project will be graded based on the following criteria:
Proper application of the Queue data structure
Functionality of the program
Error handling
Code readability and commenting
Documentation
. Your program should include
the Queue code which is included with this code below
class QueueApp
{
public static void main(String[] args)
{
Queue theQueue = new Queue(5); // queue holds 5 items
theQueue.insert(10); // insert 4 items
theQueue.insert(20);
theQueue.insert(30);
theQueue.insert(40);
theQueue.remove(); // remove 3 items
theQueue.remove(); //(10,20,30)
theQueue.remove();
theQueue.insert(50); // insert 4 more items
theQueue.insert(60); //(wraps around)
theQueue.insert(70);
theQueue.insert(80);
while(!theQueue.isEmpty())// remove and display
{// all items
long n = theQueue.remove(); //(40,50,60,70,80)
System.out.print(n);
System.out.print("");
}
System.out.println("");
}// end main()
}// end class QueueApp
class Queue
{
private int maxSize;
private long[] queArray;
private int front;
private int rear;
private int nItems;
//--------------------------------------------------------------
public Queue(int s)// constructor
{
maxSize = s;
queArray = new long[maxSize];
front =0;
rear =-1;
nItems =0;
}
//--------------------------------------------------------------
public void insert(long j)// put item at rear of queue
{
if(rear == maxSize-1)// deal with wraparound
rear =-1;
queArray[++rear]= j; // increment rear and insert
nItems++; // one more item
}
//--------------------------------------------------------------
public long remove()// take item from front of queue
{
long temp = queArray[front++]; // get value and incr front
if(front == maxSize)// deal with wraparound
front =0;
nItems--; // one less item
return temp;
}
//--------------------------------------------------------------
public long peekFront()// peek at front of queue
{
return queArray[front];
}
//--------------------------------------------------------------
public boolean isEmpty()// true if queue is empty
{
return (nItems==0);
}
//--------------------------------------------------------------
public boolean isFull()// true if queue is full
{
return (nItems==maxSize);
}
//--------------------------------------------------------------
public int size()// number of items in queue
{
return nItems;
}
//--------------------------------------------------------------
}// end class Queue

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 Databases Questions!