[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, a month (number), and the number of days of the month.
* 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 );
String strm = JOptionPane. showInputDialog ("Enter the month to be judged ;");
Int m = Integer. parseInt (strm );
System. out. println ("the month you entered is:" + m );
If (jud (y ))
{
System. out. println (y + "is a leap year .");
}
Else
{
System. out. println (y + "not a leap year ");
}
Int d = fig (m );
If (jud (y ))
{
If (m = 2)
{
++ D;
}
System. out. println ("the number of days you entered this month is:" + d );
}
Else
{
System. out. println ("the number of days you entered this month is:" + d );
}
}
Public static boolean jud (int y)
{
If (y % 400 = 0 | y % 4 = 0 & y % 100! = 0)
{
Return true;
}
Else
{
Return false;
}
}
Public static int fig (int m)
{
Switch (m)
{
Case 1:
Return 31;
Case 2:
Return 28;
Case 3:
Return 31;
Case 4:
Return 30;
Case 5:
Return 31;
Case 6:
Return 30;
Case 7:
Return 31;
Case 8:
Return 31;
Case 9:
Return 30;
Case 10:
Return 31;
Case 11:
Return 30;
Case 12:
Return 31;
Default:
System. out. println ("sorry, the month you entered is incorrect! ");
Return 0;
}
}
}