闰年测试
一、軟件界面
二、核心代碼
1 <% 2 String s = null; 3 s = request.getParameter("input"); 4 if (!s.matches("[1-9][0-9]*|0")) { 5 6 out.println("The input is not a positive interger"); 7 } else { 8 9 int a = Integer.parseInt(s); 10 11 if (a % 4 == 0 && a % 100 != 0) { 12 out.println(a + " is a leap year"); 13 } else if (a % 400 == 0) { 14 out.println(a + " is a leap year"); 15 } else { 16 out.println(a + " is not a leap year"); 17 } 18 } 19 %>三、測試用例
1.輸入中文
結果:
2.輸入英文
結果:
3.輸入特殊字符
結果:
4.輸入負數的閏年
結果:
5.輸入閏年2007
6.輸入閏年2004
轉載于:https://www.cnblogs.com/airjasonsu/p/4396359.html
總結
- 上一篇: 百事公司任命陈文渊担任亚太区首席执行官
- 下一篇: 微信开年大作:把元宇宙装进小程序