Why is this not accepting my answer? I have the correct output.
2002
Number of days in the year: 365
Process finished with exit code 0
The program should display text on the screen according to the task conditions.
Check why the program doesn't display anything.
If the entered year is a leap year, you should display: "Number of days in the year: 366".
The displayed text does not match the conditions.package com.codegym.task.task04.task0414;
/*
Number of days in the year
int x = 366
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String year = reader.readLine();
int intYear = Integer.parseInt(year);
int leapYearFourHundred = intYear % 400;
int leapYearFour = intYear % 4;
int ordinaryYearOneHundred = intYear % 100;
if (leapYearFour != 0) {
int x = 365;
System.out.println("Number of days in the year: " + x);
return;
}
if (ordinaryYearOneHundred != 0) {
int x = 366;
System.out.println("Number of days in the year: " + x);
return;
}
if (leapYearFourHundred != 0) {
int x = 365;
System.out.println("Number of days in the year: " + x);
return;
}
if (leapYearFour != 0 && ordinaryYearOneHundred != 0 && leapYearFourHundred != 0){
int x = 366;
System.out.println("Number of days in the year: " + x);
return;
}
}
}