I do not know what is wrong here. it is working perfectly if i am running without verification but if i try to verify, it shows correct for leap year, but incorrect for normal year. here is the code.
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
String s1 = read.readLine();
int n1 = Integer.valueOf(s1);
int x = 0;
if((n1 % 4 == 0) && (n1 % 400 == 0)){
x = 366;
System.out.println("Number of days in the year: "+x);}
else if((n1 % 100 == 0) && (n1 % 400 != 0)){
x = 365;
System.out.println("Number of days in the year: "+x);}
else if((n1 % 4 == 0 ) && (n1 % 100 != 0)){
x = 366;
System.out.println("Number of days in the year: "+x);}
}
}
package com.codegym.task.task04.task0414;
/*
Number of days in the year
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
String s1 = read.readLine();
int n1 = Integer.valueOf(s1);
int x = 0;
if((n1 % 4 == 0) && (n1 % 400 == 0)){
x = 366;
System.out.println("Number of days in the year: "+x);}
else if((n1 % 100 == 0) && (n1 % 400 != 0)){
x = 365;
System.out.println("Number of days in the year: "+x);}
else if((n1 % 4 == 0 ) && (n1 % 100 != 0)){
x = 366;
System.out.println("Number of days in the year: "+x);}
}
}