Computer Science, asked by anurima85, 27 days ago

write a java program that reads a 4 digit year and test whether it is leap year or not

Answers

Answered by manuprajapati519
4

Answer:

Hey mate..This is the answer for your question :)

If you liked it please mark my answer as Brainliest and follow for more.

Thank you:)

Explanation:

import java.util.Scanner;

public class leap

{

public static void main(String args [])

{

int a;

Scanner in = new Scanner(System.in);

System.out.println("Input a Year");

a=in.nextInt();

if(a<=9999)

{

if((a>=999)&&(a%4==0))

{

System.out.println("This year is a leap year "+a);

}

else if(a>=999)

{

System.out.println("Four digit year but not leap");

}

else

{

System.out.println("Invalid Year");

}

}

else

{

System.out.println("Invalid Year");

}

}

}

Similar questions