Leap year Test

Source: Internet
Author: User

First, the experimental requirements

Enter the year (you can also enter characters, letters, negative numbers, and so on) to determine whether the year entered is leap years, illegal characters (letters, symbols, etc.), and negative numbers to give hints.

Second, leap year judgment

1, the normal year can be divisible by 4 and not divisible by 100 for leap years; (as 2012 is a leap, 1900 is not a leap year)

2, the whole hundred years can be divisible by 400 is a leap year. (as 2000 is a leap year, 1900 is not a leap year)

Third, the Code

1<%@ page language= "java" import= "java.util.*" pageencoding= "Utf-8"%>2<%3String Path =Request.getcontextpath ();4String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";5%>6<%request.setcharacterencoding ("Utf-8"); %>7<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >89<script type= "Text/javascript" >Ten     functionfunc () One     { A         varInputarray =NewArray (3); -         varAlertstr =NewArray ("is a leap year", "not a leap year", "is an illegal character", "is a negative number")); -         varreg =/^[-0-9]+$/;//regular expressions represent numbers and negative signs the         vars = document.getElementById (0). Value; -          -         if(!s.match (REG)) inputarray[0] = 2; -         Else{ +                 if(S.match (REG) < 0) Inputarray[0] = 3; -                 Else{ +                     if((s% 400 = = 0) | | ((s% 4 = = 0) && (s% 100! = 0))) AInputarray[0] = 0; at                     ElseInputarray[0] = 1; -                 } -         } -          -Tips = ""; -index = inputarray[0]; inTips + = "input" +alertstr[index]+ "\ n"; - alert (tips); to         } +</script> - the<base href= "<%=basePath%>" > *      $<title>MyPage</title>Panax Notoginseng<meta http-equiv= "Pragma" content= "No-cache" > -<meta http-equiv= "Cache-control" content= "No-cache" > the<meta http-equiv= "Expires" content= "0" > +<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" > A<meta http-equiv= "description" content= "MyPage" > the<link href= "./css/bootstrap.min.css" rel= "stylesheet" media= "screen" > + -<center> $<form> $<font size=4> leap Year test </font><br> -<div class= "Container-fluid" > -<div class= "Row-fluid" > the<div class= "Span12" > -<form class= "Form-horizontal" >Wuyi<div class= "Control-group" > the<label class= "Control-label" for= "Inputemail" ><br> Please enter the year:</label> -<div class= "Controls" > Wu<input class= "Form-control" name= "0" id= "0" size= "ten" size= "maxlength=15/>" -</div> About</div> $                  -<div class= "Control-group" > -<div class= "Controls" > -<br><button class= "btn btn-primary btn-block" type= "button" name= "button" id= "button" onclick= "func ();" > OK </button></a> A</div> +</div> the</form> -</div> $</div> the</div> the</form> the</center> the

Four, the interface

  

V. Test Cases

The total set of 6 test cases:

Number Test Cases Expected results
1 400 Enter a leap year
2 1900 The input is not a leap year
3 2000 Enter a leap year
4 2015 The input is not a leap year
5 Asd An illegal character was entered.
6 -2015 The input is a negative number

Vi. test Results

Leap year Test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.