Descriptio: I am learning about debugging and simulation. however i keep gettings this error line on my code. see the pics

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

package queuedemo;

class Queue {

int front, rear, size;

    int capacity;

    int array[];

 

    public Queue(int cap)

    {

        capacity = cap;

        front=size=0;

        rear=capacity-1;

        array = new int[capacity];

    }

    

    // Method to add an item to the queue.

    void enqueue(int item)

    {

        if(isFull()) {

            System.out.println("Queue overflow");

            return;

        }

        rear=(rear+1)%capacity;

        array[rear]=item;

        size=size+1;

    }

 

    // Queue is empty when size is 0

    boolean isEmpty()

    {

        return (size == 0);

    }

 

    // Queue is full when size becomes equal to the capacity

    boolean isFull()

    {

        return (size == capacity);

    }

 

    // Method to remove an item from queue.

    int dequeue()

    {

        if (isEmpty())

            System.out.println("Queue Underflow");

            return;

        }

        int item = array[front];

        front = (front + 1)% this.capacity;

        size = size - 1 ;

        return item;

    }

 

    // Method to get front of queue

    int front()

    {

        return array[front];

    }

 

    // Method to get rear of queue

    int rear()

    {

        return array[rear];

    }

}

 

 

new file:

 

package DSA;

public class QueueTester {

public static void main(String[] args){
Queue q = new Queue(5);
q.enqueue(5);
System.out.println("front:"+q.front());

q.enqueue(3);

System.out.println("rear:"+q.rear());

q.enqueue(7);

System.out.println("front:"+q.front());

q.enqueue(9);

System.out.println("rear:"+q.rear());

q.enqueue(11);

System.out.println("front:"+q.front());

System.out.println("rear:"+q.rear());

q.enqueue(15);

q.dequeue();

q.dequeue();

System.out.println("front:"+q.front());

System.out.println("rear:"+q.rear());

q.dequeue();

q.dequeue();

q.dequeue();

q.dequeue();
}

}

 

Descriptio: I am learning about debugging and simulation. however i keep gettings this error line on my code. see the pics

70
71
72
73
74
75
76
770
78
79
80
81
82
83
84
V 85
86
87
88
89e
90
91
92
}
// Method to remove an item from queue.
int dequeue( )
{
if (isEmpty())
System.out.println("Queue Underflow");
return;
www
}
int item = array[front]; {;
front = (front + 1)% this.capacity;
93
94
size = size
1 ;
9 95
96
97
return item:
}
98
Transcribed Image Text:70 71 72 73 74 75 76 770 78 79 80 81 82 83 84 V 85 86 87 88 89e 90 91 92 } // Method to remove an item from queue. int dequeue( ) { if (isEmpty()) System.out.println("Queue Underflow"); return; www } int item = array[front]; {; front = (front + 1)% this.capacity; 93 94 size = size 1 ; 9 95 96 97 return item: } 98
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY