QuestionQuestion

In this programming assignment you are required to implement a queue data structure using a singly linked list. Write a Java program to implement the queue using a simple linked list instead of a fixed size array. You can assume the items to be stored in the queue are positive integers. You do not need to incorporate any ordering. However, the queue must have a front and a rear. Any item inserted to the queue will be inserted at rear and items must be deleted from front.

Programming:
Your main() method should be interactive (menu driven) and should give the following options to a
user:
i) Insert an item to the queue (at rear)
ii) Delete an item from the queue (from front)
iii) Display the item at front
iv) Display the item at rear
v) Display total number of items currently present in the queue
vi) Print the items currently present in the queue
vii) Quit
The program should start with the menu and the user should be able to choose any option from the menu. The menu should keep coming back, after completing each user choice, until the user selects ‘Quit’ option. Also, include proper error checking (for example, when someone tries to delete item from an empty queue, or tries to display items of an empty queue) with appropriate message(s).

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

public class LinkedlistQue {

    /**
    * private class holds data and connection to other item in the list
    */
    private class Node{      
       int item; // data
       Node next; // connector
       /**
         * constructor
         * @param item
         * @param next
         */
       public Node(int item, Node next) {
            this.item = item;
            this.next = next;
       }      
    };
      
    private Node front; // front reference   
    private Node rear; // rear reference
    private int total;// number of item in queue...
$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats