Java Reference
In-Depth Information
String set3 =
set3
17
18
" 4 5 6 7\n" +
19
"12 13 14 15\n" +
20
"20 21 22 23\n" +
21
"28 29 30 31" ;
22
23
24
String set4 =
set4
" 8 9 10 11\n" +
25
"12 13 14 15\n" +
26
"24 25 26 27\n" +
27
"28 29 30 31" ;
28
29
30
String set5 =
set5
"16 17 18 19\n" +
31
"20 21 22 23\n" +
32
"24 25 26 27\n" +
33
"28 29 30 31" ;
34
35
int day = 0 ;
36
37
// Prompt the user to answer questions
38
39
40
41
42 day += 1 ;
43
44 answer = JOptionPane.showConfirmDialog( null ,
45
int answer = JOptionPane.showConfirmDialog( null ,
confirmation dialog
"Is your birthday in these numbers?\n" + set1);
if (answer == JOptionPane.YES_OPTION)
in set1?
"Is your birthday in these numbers?\n" + set2);
46
47 if (answer == JOptionPane.YES_OPTION)
48 day += 2 ;
49
50 answer = JOptionPane.showConfirmDialog( null ,
51
in set2?
"Is your birthday in these numbers?\n" + set3);
52
53 if (answer == JOptionPane.YES_OPTION)
54 day += 4 ;
55
56 answer = JOptionPane.showConfirmDialog( null ,
57
in set3?
"Is your birthday in these numbers?\n" + set4);
58
59 if (answer == JOptionPane.YES_OPTION)
60 day += 8 ;
61
62 answer = JOptionPane.showConfirmDialog( null ,
63
in set4?
"Is your birthday in these numbers?\n" + set5);
64
65 if (answer == JOptionPane.YES_OPTION)
66 day += 16 ;
67
68 JOptionPane.showMessageDialog( null , "Your birthday is " +
69 day + "!" );
70 }
71 }
in set5?
The program displays confirmation dialog boxes to prompt the user to answer whether a
number is in Set1 (line 38), Set2 (line 44), Set3 (line 50), Set4 (line 56), and Set5 (line 62). If
the answer is Yes, the first number in the set is added to day (lines 42, 48, 54, 60, and 66).
Search WWH ::




Custom Search