Blogger Information
Blog 27
fans 0
comment 0
visits 22439
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
if else判断 - 第五期0325作业
不乖的博客
Original
979 people have browsed it

实例

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<!--
			【案例1】判断是否为闰年
			【案例2】给学生的具体成绩划分等级,优秀(90-100)、良好(80-89)、良(70-79)、及格(60-69)、
			不及格(0-59),输出该学生的成绩是哪个阶段
		-->
		<script>
			/*1.判断是否为闰年*/
			/*普通闰年:能被4整除但不能被100整除的年份为普通闰年。(如2004年就是闰年,1999年不是闰年);
			世纪闰年:能被400整除的为世纪闰年。(如2000年是世纪闰年,1900年不是世纪闰年);*/
			/* b / a = c ....0  b能被a整除*/
			var LeapYear = 2004;
			if(LeapYear%4==0 && LeapYear%100!=0){
				alert(LeapYear+'是普通闰年');
			}else if(LeapYear%400==0){
				alert(LeapYear+'是世纪闰年');
			} else {
				alert(LeapYear+'不是闰年');
			}
			
			
			/*2.成绩划分*/
			var grade =90;
			if(grade<=59){
				alert(grade+'成绩不及格');
			} else if(grade>=60&&grade<=69){
				alert(grade+'成绩及格');
			} else if(grade>=70&&grade<=79){
				alert(grade+'成绩良');
			}else if(grade>=80&&grade<=89){
				alert(grade+'成绩良好');
			} else {
				alert(grade+'成绩优秀');
			}
		</script>
	</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post