Computer Science, asked by guptaaditya511, 1 year ago

Write a program to read a from the user and check whether leap year or not

Answers

Answered by Punya2138
1

import java.io.*;

class Leap

{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int a;

public void accept()throws IOException

{ System.out.println("Enter a year");

a=Integer.parseInt(br.readLine());

}

public void calc()

{ if(a%4==0)

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

else

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

}

}

Answered by shirisha1981
0

Answer:import java.io.*;

class LeapYear

{

    public static void main(String args[])throws IOException {

BufferedReader ob = new BufferedReader( new InputStreamReader (System.in));

int year;

System.out.println("Enter any year to check if it's a leap year..");

year=Integer.parseInt(ob.readLine());

if( (year%4==0)&&(year%400==0) ) {

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

 }

else if(year%100!=0) {

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

 }

else {

  System.out.println(year +" is not an leap year");

 }                  

}

}

Similar questions