编写一个程序,提示用户输入一年和一个月的前三个字母名称(第一个字母为大写),并显示该月的天数。 这是一个示例运行:
输入年份:2001年
输入一个月:Jan
“2001年1月有31天”
输入年份:2016年
输入一个月:2月
“2016年1月有29天”(我不明白这一点)我的问题是闰年部分。 我不明白如何使用该程序的其余部分,因为天数应该改变。 我也不明白为什么“2月”的月份在示例中变为“Jan”。 我需要帮助改造我的程序。 我可以使用的是以下代码中所见:“”“如果语句和开关/案例。”“”
import java.util.Scanner;
public class NewClass {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a year: ");
int year = input.nextInt();
input.nextLine();
System.out.print("Enter a month: ");
String month = input.nextLine();
// Taken from the book per request of the instructor
boolean isLeapYear = ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
s