Computer Science, asked by Anonymous, 9 months ago

please solve the program using scanner class.
And please if don't know then please don't post irrelevant answers.​

Attachments:

Answers

Answered by poojan
3

Language Used : Python Programming, Java Programming.

Note :

Please check the attachment given below to see the compilation and interpretation of the programs mentioned.

Program (Java) :

import java.util.Scanner;

public class Something

{

   public static void main(String[] args)

   {

     Scanner sc= new Scanner(System.in);

     int year = sc.nextInt();

     if(year % 4 == 0)

       {

           if( year % 100 == 0)

           {

               

               if ( year % 400 == 0)

                   System.out.println("It is a Century Leap Year");

               else

                   System.out.println("It is a Century year but not a Leap year");

           }

           else

               System.out.println("It is a Leap year");

       }

       else

           System.out.println("It is neither a Leap year nor a Century year");

   }

}

Program (Python) :

year=int(input())

if (year % 4) == 0:

   if (year % 100) == 0:

       if (year % 400) == 0:

           print("It is a Century Leap Year")

       else:

           print("It is a Century year but not a Leap year")          

   else:  

       print("It is a Leap year")

else:

   print("It is neither a Leap year nor a Century year")

Inputs :

Input 1 : 2000

Input 2 : 1996

Input 3 : 1900

Input 4 : 1993

Outputs :

Output 1 : It is a Century Leap Year

Output 2 : It is a Leap year

Output 3 : It is a Century year but not a Leap year

Output 4 : It is neither a Leap year nor a Century year

Explanation :

Leap year : Which is divisible by 4, but not by 100. Example : 1996

Century Leap year : Which is divisible by 4, 100 and 400. Example : 2000

Century but not Leap : Which is divisible by 100, but not by 4. Example : 1900

Neither Leap nor Century : Which isn't divisible both 4 and 100. Example : 1993

Hope it helps. If yes, leave a smile. :)

Attachments:
Similar questions