Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0fe1d72

Browse files
Complete Assignments
1 parent 0b091c9 commit 0fe1d72

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

ch05/Switch.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class Switch
2+
{
3+
public static void main(String[] args)
4+
{
5+
int month = 2, year = 2018, num = 31;
6+
7+
8+
switch (month)
9+
{
10+
case 4 : case 6 : case 9 : case 11 : num = 30;break;
11+
case 2 : num = ( year % 4 == 0 ) ? 29 : 28 ; break;
12+
13+
}
14+
15+
System.out.println( month + "/" + year + ":" + num + "days");
16+
}
17+
}

ch05/SwitchExample.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class SwitchExample
2+
{
3+
public static void main(String[] args)
4+
{
5+
lastNamewinner("Smith");
6+
}
7+
8+
private static void lastNamewinner(String name)
9+
{
10+
/* switch (name)
11+
{
12+
case "Smith":
13+
case "Jones":
14+
name = System.out.println("Congratulations, grand winner");
15+
break;
16+
}
17+
*/
18+
19+
}
20+
}

0 commit comments

Comments
 (0)