Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Mod10Slide26 {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         Scanner k = new Scanner(System.in);
  8.         ArrayList<String> calls = new ArrayList<String>();
  9.  
  10.         int option;
  11.         String input = "";
  12.        
  13.         System.out.println("Call Center System\n\n");
  14.         System.out.println("1) Add a number");
  15.         System.out.println("2) Retrieve next number");
  16.         System.out.println("3) Show all numbers waiting for callback");
  17.         System.out.println("4) Exit");
  18.         System.out.print("Enter your option: ");
  19.         option = Integer.parseInt(k.nextLine());
  20.        
  21.         while (option != 4) {
  22.             switch (option) {
  23.                 case 1:
  24.                     System.out.printf("Enter callback #: ");
  25.                     input = k.nextLine();
  26.                     calls.add(input);
  27.                     break;
  28.                 case 2:
  29.                     String nextCall = calls.get(0);
  30.                     calls.remove(0);
  31.                     System.out.printf("Next phone number to call: %s\n", nextCall);
  32.                     break;
  33.                 case 3:
  34.                     System.out.println("Callback list\n");
  35.                     System.out.printf("%8s %12s\n", "Position", "Number");
  36.                    
  37.                     for (int i = 0; i < calls.size(); i++) {
  38.                         System.out.printf("%-8d %12s\n", i + 1, calls.get(i));
  39.                     }
  40.                     System.out.println();
  41.                     break;
  42.             }
  43.             System.out.println("Call Center System\n\n");
  44.             System.out.println("1) Add a number");
  45.             System.out.println("2) Retrieve next number");
  46.             System.out.println("3) Show all numbers waiting for callback");
  47.             System.out.println("4) Exit");
  48.             System.out.print("Enter your option: ");
  49.             option = Integer.parseInt(k.nextLine());
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement