首页题目详情

提示用户输入月份和年份,然后显示这个月的天数。

问答题
2020-02-27 11:19:00
0233
参考答案: 提示用户输入月份和年份,然后显示这个月的天数。 public class ExamDemo {        public static void main(String[] args) {               java.util.Scanner input = new java.util.Scanner(System.in);               System.out.print("Enter a month in the year (e.g., 1 for Jan): ");               int month = input.nextInt();               System.out.print("Enter a year: ");               int year = input.nextInt();               int numberOfDaysInMonth = 0;               switch (month) {                      case 1:                             System.out.print("January " + year);                             numberOfDaysInMonth = 31;                             break;                      case 2:                             System.out.print("February " + year);                             if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))                                    numberOfDaysInMonth = 29;                             else                                    numberOfDaysInMonth = 28;                             break;                      case 3:                             System.out.print("March " + year);          &n...
查看答案
 参考答案
科目:JAVA程序设计
学科:计算机科学与技术