Skip to content
Snippets Groups Projects
Commit 505ba794 authored by lbr's avatar lbr
Browse files

Switch challenges

parent c7d300d7
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -13,7 +13,11 @@ public class Main { ...@@ -13,7 +13,11 @@ public class Main {
String month = "aprilr"; String month = "aprilr";
System.out.println(month + " is in the " + getQuarter(month) + " quarter");*/ System.out.println(month + " is in the " + getQuarter(month) + " quarter");*/
// System.out.println(getNATO('x')); // System.out.println(getNATO('x'));
getDayOfTheWeek(3); // getDayOfTheWeek(3);
System.out.println(isLeapYear(-1600));
System.out.println(isLeapYear(1600));
System.out.println(isLeapYear(2017));
System.out.println(isLeapYear(2000));
} }
public static String getQuarter(String month) { public static String getQuarter(String month) {
...@@ -59,4 +63,29 @@ public class Main { ...@@ -59,4 +63,29 @@ public class Main {
}; };
System.out.println(dayOfTheWeek); System.out.println(dayOfTheWeek);
} }
public static boolean isLeapYear(int year){
if (year <= 1 || year >= 9999) {
System.out.print("Invalid year!: ");
return false;
}
if(year % 4 == 0) {
if (year % 100 != 0) {
System.out.print("Year is divisible by 4 and not by 100.: ");
return true;
} else {
if (year % 400 == 0){
System.out.print("Year is divisible by 4, by 100 and by 400.: ");
return true;
}
else {
System.out.print("Ordinary leap year.: ");
return false;
}
}
} else {
System.out.print("Not divisible by 4.: ");
return false;
}
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment