Skip to content

Commit 6995a19

Browse files
Complete Assignments
1 parent 0fe1d72 commit 6995a19

1 file changed

Lines changed: 44 additions & 4 deletions

File tree

‎ch05/SwitchExample.java‎

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,60 @@
1+
import java.sql.SQLOutput;
2+
13
public class SwitchExample
24
{
35
public static void main(String[] args)
46
{
5-
lastNamewinner("Smith");
7+
lastNamewinner("Jones");
8+
dayOfWeek(5);
69
}
710

811
private static void lastNamewinner(String name)
912
{
10-
/* switch (name)
13+
switch (name)
1114
{
1215
case "Smith":
16+
System.out.println("Congratulations, grand winner");
17+
break;
1318
case "Jones":
14-
name = System.out.println("Congratulations, grand winner");
19+
System.out.println("Congratulations, grand winner");
1520
break;
21+
case "Lazenby":
22+
System.out.println("Hey, he owes me dinner");
23+
break;
24+
default:
25+
System.out.println("Sorry, not a winner");
1626
}
17-
*/
1827

28+
29+
}
30+
31+
private static void dayOfWeek(int day)
32+
{
33+
switch (day)
34+
{
35+
case 1:
36+
System.out.println("Sunday");
37+
break;
38+
case 2:
39+
System.out.println("Monday");
40+
break;
41+
case 3:
42+
System.out.println("Tuesday");
43+
break;
44+
case 4:
45+
System.out.println("Wednesday");
46+
break;
47+
case 5:
48+
System.out.println("Thursday");
49+
break;
50+
case 6:
51+
System.out.println("Friday");
52+
break;
53+
case 7:
54+
System.out.println("Satday");
55+
break;
56+
default :
57+
System.out.println("Invalid value: " + day);
58+
}
1959
}
2060
}

0 commit comments

Comments
 (0)