📄 ch3_e3_14.java
字号:
import java.io.*;
public class ch3_e3_14
{
public static void main(String args[])
{
int i=0;
do
{
try
{
System.out.println("请输入1~12之间的一个整数:");
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
i = Integer.parseInt(s);
}
catch(NumberFormatException nfe)
{
System.out.println("输入格式错误。");
i = -1;
}
catch(IOException ioe)
{
System.err.println(ioe.toString());
System.exit(0);
}
}while( i<1 || i>12 );
switch(i)
{
case 1:
System.out.println("1月份有31天。");
break;
case 2:
System.out.println("2月份有28或29天。");
break;
case 3:
System.out.println("3月份有31天。");
break;
case 4:
System.out.println("4月份有30天。");
break;
case 5:
System.out.println("5月份有31天。");
break;
case 6:
System.out.println("6月份有30天。");
break;
case 7:
System.out.println("7月份有31天。");
break;
case 8:
System.out.println("8月份有31天。");
break;
case 9:
System.out.println("9月份有30天。");
break;
case 10:
System.out.println("10月份有31天。");
break;
case 11:
System.out.println("11月份有30天。");
break;
case 12:
System.out.println("12月份有31天。");
break;
}
}//end of main method
}//end of class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -