int daysInNonLeapYear = 365;
int daysInLeapYear = 366;
if (year % 400 == 0) {
System.out.println("Number of days in the year: " + daysInLeapYear + ".");
} else if (year % 100 == 0) {
System.out.println("Number of days in the year: " + daysInNonLeapYear + ".");
} else if (year % 4 == 0) {
System.out.println("Number of days in the year: " + daysInLeapYear + ".");
} else {
System.out.println("Number of days in the year: " + daysInNonLeapYear + ".");
}
What's wrong with my code? It seems to be working when i test it out
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Anthony Chalk
10 December 2019, 10:39
Get rid of the "." in each print command
0