*4.17(一个月的天数)编写一个程序,提示用户输入一个年份和一个月份名称的前三个字母(第一个字母使用大写形式),显示该月中的天数。如果输入的月份是非法的,显示一条出错信息。
下面是一个运行示例:
Enter a year: 2001
Enter a month: Jan
Jan 2001 has 31 days
Enter a year: 2016
Enter a month: jan
jan is not a correct month name
*4.17(Days of a month) Write a program that prompts the user to enter the year and the first three letters of a month name (with the first letter in uppercase) and displays the number of days in the month. If the input for month is incorrect, display a message as presented in the following sample runs:
Enter a year: 2001
Enter a month: Jan
Jan 2001 has 31 days
Enter a year: 2016
Enter a month: jan
jan is not a correct month name
下面是参考答案代码:
import java.util.*;
public class DaysOfMonthQuestion17 {
public static void main(String[] args) {
int year;
String month;
Scanner input = new Scanner(System.in);
System.out.print("Enter a year:");
year = input.nextInt();
System.out.print("Enter a month:");
month = input.nex