Java -- about a leap year

Source: Internet
Author: User

[Java]
/* (Start of program header annotation) </p> <p> * copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* Author: Li Zhaoqing
* Completion date: January 1, September 22, 2012
* Input description:
* Problem description and output: run java: enter a year on the keyboard to determine whether it is a leap year.
* End the comment in the program Header
*/
 
Import javax. swing. JOptionPane;
Public class Num {

/**
* @ Param args
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
String str = JOptionPane. showInputDialog ("Enter the year to be determined ;");

Int y = Integer. parseInt (str );

System. out. println ("the year you entered is:" + y );

If (jud (y ))
{
System. out. println (y + "is a leap year .");
}
Else
{
System. out. println (y + "not a leap year ");
}
}
 
Public static boolean jud (int y)
{
If (y % 400 = 0 | y % 4 = 0 & y % 100! = 0)
{
Return true;
}
Else
{
Return false;
}
}

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.