Problem 10:
Write a program that
take year from the user and check it is leap or not
Discripition:
If year modulus 4 is
equal to zero then year is leap.
Solution:
import java.util.*;
public class Message {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.println("Enter the
year");
int num=input.nextInt();
if(num%4==0)
System.out.println("This is leap year
"+num);
else
System.out.println("This is not leap
year "+num);
}}
Output:
No comments:
Post a Comment