SHOW:
|
|
- or go back to the newest paste.
1 | - | public class mod8slide34 |
1 | + | import java.util.Scanner; |
2 | - | { |
2 | + | |
3 | - | public static void main (String [] args) |
3 | + | public class Mod10Slide26 { |
4 | - | { |
4 | + | |
5 | - | Scanner k = new Scanner (System.in); |
5 | + | public static void main(String[] args) { |
6 | - | double grade = 0; |
6 | + | |
7 | - | System.out.print ("Enter the grade: "); |
7 | + | Scanner k = new Scanner(System.in); |
8 | - | grade = k.nextDouble(); |
8 | + | ArrayList<String> calls = new ArrayList<String>(); |
9 | - | if (isValidGrade(grade)) |
9 | + | |
10 | - | { |
10 | + | int option; |
11 | - | System.out.println (grade + " is a valid grade."); |
11 | + | String input = ""; |
12 | - | } |
12 | + | |
13 | - | else |
13 | + | System.out.println("Call Center System\n\n"); |
14 | - | { |
14 | + | System.out.println("1) Add a number"); |
15 | - | System.out.println (grade + " is out of range."); |
15 | + | System.out.println("2) Retrieve next number"); |
16 | - | } |
16 | + | System.out.println("3) Show all numbers waiting for callback"); |
17 | - | } |
17 | + | System.out.println("4) Exit"); |
18 | - | public static boolean isValidGrade (double grade) |
18 | + | System.out.print("Enter your option: "); |
19 | - | { |
19 | + | option = Integer.parseInt(k.nextLine()); |
20 | - | boolean r |
20 | + | |
21 | - | if (grade >= 0 || grade <= 100) { |
21 | + | while (option != 4) { |
22 | - | r = true; |
22 | + | switch (option) { |
23 | case 1: | |
24 | - | else { |
24 | + | System.out.printf("Enter callback #: "); |
25 | - | r = false; |
25 | + | input = k.nextLine(); |
26 | calls.add(input); | |
27 | - | return r; |
27 | + | break; |
28 | - | } |
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 | } |