Isn't it true that all years that are leap years are divided by 4?
In which case I do not need to check if it is also divisible by 400, nor do I need to find out if it is divisible by 100.
A simple if-else should suffice.
It's not passing, even though I've been checking with various numbers, both large and small,
package com.codegym.task.task04.task0414;
/*
Use the keyboard to enter a year,
and then determine the number of days in the year.
Display the result as follows:
Number of days in the year: x
, where
x is 366 for a leap year, and
x is 365 for an ordinary year.
Hint:
A leap year is 366 days, but an ordinary year is 365 days.
1) if the year is evenly divisible by 400, then it is a leap year;
2) for other years, if the year is evenly divisible by 100, then it is a regular year;
3) for other years, if the year is evenly divisible by 4, then it is a leap year;
4) all remaining years are not leap years.
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
String inYear = r.readLine();
int conYear = Integer.parseInt(inYear);
if (conYear%4 == 0)
{
int x = 366;
System.out.println("Number of days in the year: "+x);
}
else
{
int x = 365;
System.out.println("Number of days in the year: "+x);
}
}
}