⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 leap.java

📁 能算出某個月份有多少天(輸入2月時需要輸入年份)
💻 JAVA
字号:
import javax.swing.*;
public class leap	{
	public static void main ( String args[] )	{
		String month,year,month1[]={"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec" };
		int months,years = 0,num1;
		int day[]={31,0,31,30,31,30,31,31,30,31,30,31};
		int num[]=new int[11];
		month = JOptionPane.showInputDialog("Enter a month");
		months = Integer.parseInt(month);
		if (months == 2){	
		year = JOptionPane.showInputDialog("Enter a year");
			years = Integer.parseInt(year);}
				if ((((years % 4 == 0) && (years % 100 != 0)) || 
					(years % 400 == 0)))
			num1 = 29;
				else
			num1 = 28;
		if (months==2)
			JOptionPane.showMessageDialog( null, "The number of days on month Feb is : "
				+ num1,"Message", JOptionPane.INFORMATION_MESSAGE );
		else
			JOptionPane.showMessageDialog( null, "The number of days on month " + month1[months-1] +" is : "
				+ day[months-1],"Message", JOptionPane.INFORMATION_MESSAGE );

	System.exit( 0 );
	}
}
		
				

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -