/* The return statement is the simplest of the
* branching statements. It is used to exit
* the current method and return a value.
*/
public static String month1 (int value) {
String a = "Welcome to January!";
return a;
}
public static String month2 (int value) {
String a = "Welcome to February!";
return a;
}
public static String month3 (int value) {
String a = "Welcome to March!";
return a;
}
public static String month4 (int value) {
String a = "Welcome to April!";
return a;
}
public static void main(String[] args) {
String text = "If I wasn't so lazey the year would be complete.";
for (int month = 1; month <= 12; month++) {
switch (month) {
case 1:
System.out.println(month1(month));
break;
case 2:
System.out.println(month2(month));
break;
case 3:
System.out.println(month3(month));
break;
case 4:
System.out.println(month4(month));
break;
default:
System.out.println(text);
break;
}
}
}
}
No comments:
Post a Comment