-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemo.java
59 lines (53 loc) · 1.44 KB
/
Demo.java
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Copyright (C) Deepali Srivastava - All Rights Reserved
This code is part of DSA course available on CourseGalaxy.com
*/
package queueLinked;
import java.util.Scanner;
public class Demo
{
public static void main(String[] args)
{
int choice,x;
Scanner scan = new Scanner(System.in);
QueueL qu = new QueueL();
while(true)
{
System.out.println("1.Insert an element in the queue");
System.out.println("2.Delete an element from the queue");
System.out.println("3.Display element at the front");
System.out.println("4.Display all elements of the queue");
System.out.println("5.Display size of the queue");
System.out.println("6.Quit");
System.out.print("Enter your choice : ");
choice = scan.nextInt();
if(choice==6)
break;
switch(choice)
{
case 1:
System.out.print("Enter the element to be inserted : ");
x = scan.nextInt();
qu.insert(x);
break;
case 2:
x=qu.Delete();
System.out.println("Element deleted is : " + x);
break;
case 3:
System.out.println("Element at the front is : " + qu.peek());
break;
case 4:
qu.display();
break;
case 5:
System.out.println("Size of queue is " + qu.size());
break;
default:
System.out.println("Wrong choice");
}
System.out.println();
}
scan.close();
}
}