Write a program to print a year is leap year or not?
Answers
Answered by
2
class LeapYear
{
static void main(int year)
{
if((year % 4 == 0) && (year % 100 != 0))
{
System.out.print("year is leap year");
}
else if((year % 4 == 0) && (year % 100 == 0) && (year % 400 == 0))
{
System.out.print("year is the leap year");
}
else
{
system.out.print("year is not leap year");
}
}
}
{
static void main(int year)
{
if((year % 4 == 0) && (year % 100 != 0))
{
System.out.print("year is leap year");
}
else if((year % 4 == 0) && (year % 100 == 0) && (year % 400 == 0))
{
System.out.print("year is the leap year");
}
else
{
system.out.print("year is not leap year");
}
}
}
Answered by
1
import java.util.*;
class leap
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number to check");
int y = sc.nextInt();
int c=y%4;
if(c==0)
System.out.println("This year is a leap year");
else
System.out.println("This is not a leap year");
}
}
class leap
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number to check");
int y = sc.nextInt();
int c=y%4;
if(c==0)
System.out.println("This year is a leap year");
else
System.out.println("This is not a leap year");
}
}
Similar questions