Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner input = new Scanner(System.in);
  8.  
  9. System.out.printf("Input the queue size: ");
  10. int size = input.nextInt();
  11.  
  12. Queue que = new Queue(size);
  13.  
  14. while (true) {
  15. System.out.println("\n1. Enqueue\n2. Dequeue\n3. View Queue\n");
  16. int choice = input.nextInt();
  17.  
  18. if (choice == 1) {
  19. System.out.printf("Value to insert: ");
  20. int value = input.nextInt();
  21. que.enqueue(value);
  22. }
  23. else if (choice == 2) {
  24. que.dequeue();
  25. }
  26. else if (choice == 3) {
  27. que.view_queue();
  28. }
  29. else {
  30. break;
  31. }
  32. }
  33. input.close();
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement