第三章第十一题(给出一个月的总天数)(Find the number of days in a month)

该博客介绍了一个编程任务,要求编写程序根据用户输入的月份和年份来确定该月的天数。例如,2012年2月有29天,2015年3月有31天。此外,还强调了良好的编程习惯,如使用英文命名,详细注释,具象的变量命名和统一的代码风格。
摘要由CSDN通过智能技术生成

*3.11(给出一个月的总天数)编写程序,提示用户输入月份和年份,然后显示这个月的天数。例如:如果用户输入的月份是2而年份是2012,那么程序应该显示“February 2012 has 29 days”(2012年2月有29天)。如果用户输入的月份为3而年份为2015,那么程序就应该显示“March 2015 has 31 days”(2015年3月有31天)。

*3.11(Find the number of days in a month) Write a program that prompts the user to enter the month and year and displays the number of days in the month. For example, if the user entered month 2 and year 2012, the program should display that February 2012 has 29 days. If the user entered month 3 and year 2015, the program should display that March 2015 has 31 days.

下面是参考答案代码:

import java.util.*;

public class FindDaysInAMonthQuestion11 {
   
	public static void main(String[] args) {
   
		int year,month;
		
		System.out.print("Enter the month:");
		Scanner input = new Scanner(System.in);
		month = input.nextInt();
		
		System
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值