0


白盒测试(17-20道题目+详细代码)

白盒测试题目

**题 17:**根据输入的年份和月份判断月份的天数,并设计测试数据进行语句覆盖测试。若月份不在有效范围之内,应提示:“月份输入不正确。”。月份不为 2 月,根据输入月份输出对应的月份天数。月份为 2 月,根据年份判断如为闰年,输出 2 月份正确天数;不为闰年输出 2 月份天数。输入数据打印出“输入年:”、“输入月:”;输出内容格式:“year 年 month 月份的天数是 days 天。”year、month 为输入的值,days 为判断得到的天数值。其中变量 year、month 均须为正整数。

import java.util.Scanner;
public class demo17{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		System.out.println("输入年:");
		int year = sc.nextInt();
		System.out.println("输入月:");
		int month = sc.nextInt();
		int days;
		if(year>0){
			if(month>0&&month<=12){
				if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
					days=31;
				}else if(month&#

本文转载自: https://blog.csdn.net/heikefu/article/details/127994687
版权归原作者 雪人. 所有, 如有侵权,请联系我们删除。

“白盒测试(17-20道题目+详细代码)”的评论:

还没有评论