Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

public class Dequeue

int arrl:
int lim, front, rear;
public Dequeue(int 1) {
lim = l;

front =
rear =
0;
arr new int[l];

void addfront (int val) {


if ( front > 8) {
arr[front] = val
front-.
else
System. out.println("Overflow from front. ");
void addrear( int val) {
if (rear < lim -1) {
+rear;
arr[rear] =val;
else
System.out.printIn ( "Overflow from rear. ");
int popfront() {
if (front != rear) {
int val =
arr[front];
++front
return val;

else
return9999;
import java.util.scanner;
public class Printjob {
protected int job[ ]:
1/ to point to first & last element
protected int front, rear
in the job
protected int Capacity;
protected int Newjob;
public Printjob() {
Capacity = 20;

front -1;
rear =1;
createJob();

private void createJob()


job new int[Capacity];

boolean isEmpty() (
return front == -1;

public void addJob() {


int id ==0
System.out.println("Enter the job id of new print job:");
Scanner in = new Scanner(System.in);

try
id =
in.nextInt ()
catch(Exception e)
System.out.println(e);
Newjob = id;

if ( rear == -1){
front rear =0;
job[rear] = id;

else if( rear+1 < job.length)


job[++rear] =id;

public void removeJob () {


int elem
if(isEmpty() )
System.out.println("Printjob is empty")
else {
elem job[front] ;
if ( front == rear)
front rear =-1;
else
front ++
System.out.println("The print job removed is:" + elem)

You might also like