-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.java
More file actions
45 lines (45 loc) · 1.1 KB
/
Copy pathqueue.java
File metadata and controls
45 lines (45 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.util.Scanner;
class queue {
static int f =0, r=0, a[]=new int[5];
void display(){
if( r <= 0 || r==f )
System.out.println("The queue is empty !!");
else{
int f1 = f;
System.out.println("The queue is :: ");
while(f1 < r){
System.out.print(a[f1]+" ");
f1++;
}
System.out.println();
}
}
void insert()
{
if(r >= 5)
System.out.println("The queue is full !!");
else{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value you want to add in the queue");
int value = sc.nextInt();
a[r++] = value;
}
}
void delete()
{
if( r <= 0 || r==f )
System.out.println("The queue is empty !!");
else{
f++;
}
}
public static void main(String [] args){
queue q = new queue();
q.insert();
q.insert();
q.insert();
q.display();
q.delete();
q.display();
}
}