Mam zwrócić liczbę dni w miesiącu, ale program nie dochodzi do switcha, gdzies mam blad ktorego nie moge zlokalizowac.
BTW Jest jakis dzial dla very newbie, czy jesli postuje tutaj to jest ok?
public class NumberOfDaysInMonth {
public static boolean isLeapYear(int year) {
if (year < 1 || year > 9999) {
return false;
} else {
return ((year % 4 == 0 && year != 100) || year % 400 == 0);
}
}
public static int getDaysinMonth(int month, int year) {
if (month < 1 || month > 12 || year < 1 || year > 9999) {
return -1;
} else {
if (month == 2 && isLeapYear(year)) {
return 29;
} else {
switch (month) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
return 31;
break;
case 2:
return 28;
break;
case 4: case 6: case 9: case 11:
return 30;
break;
}
}
}
}
}