Computer Science, asked by Abhishek18111, 1 year ago

WAP to check whether the given year is a leap year or not ?

Answers

Answered by ramarekha2005
6
//
class leap
{
public static void main(int y)
{
int l= y%4;
If(l==0);
System. Out. Println("it is a leap year"+y);
else
System. Out. Println("it is not a leap year"+y);
}}

Abhishek18111: its wrong !
ramarekha2005: How
Abhishek18111: u havent checked for neither century nor non century year !
ramarekha2005: But my teacher told me like this
Abhishek18111: kk
ramarekha2005: U r in which class
Abhishek18111: i am in 11th
ramarekha2005: Ok then mine is wrong because I'm in 8th and my level is different.... Sorry
Answered by Sneha591
1
import java.util.*;
public class check
{
public static void main ()
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the year");
int n=in.nextInt();
int r=n%10;
int s=r%4;
if(s==0)
System.out.println("The year is leap year");
else
System.out.println("The year is not a leap year");
}
}

Abhishek18111: have u checked for both century n non century year both ?
Sneha591: no i checked for leap year only
Abhishek18111: i want for both years
Sneha591: okay let me try
Abhishek18111: i got it ..u dont need to worry !
Sneha591: ohk good
Abhishek18111: kk
Similar questions