lab17js
This commit is contained in:
		
							
								
								
									
										37
									
								
								Chapter ZIPs/JavaScript/ch8/ex_8_9.html
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										37
									
								
								Chapter ZIPs/JavaScript/ch8/ex_8_9.html
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
<title>Example 8.9</title>
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
var scores = new Array();
 | 
			
		||||
var sum = 0;
 | 
			
		||||
var count1 = 0;
 | 
			
		||||
var count2 = 0;	
 | 
			
		||||
var count = 0;
 | 
			
		||||
var average = 0;
 | 
			
		||||
while (scores[count1] != 999)
 | 
			
		||||
{
 | 
			
		||||
		scores[count1]= prompt("Enter the student's grade or enter 999 when you are done: ");
 | 
			
		||||
		scores[count1] = parseFloat(scores[count1]);
 | 
			
		||||
		if (scores[count1] == 999)
 | 
			
		||||
		{
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		sum = sum + scores[count1];
 | 
			
		||||
		count1 = count1 + 1;
 | 
			
		||||
}
 | 
			
		||||
average = sum / count1;
 | 
			
		||||
for (count = 0; count < count1; count++)
 | 
			
		||||
{
 | 
			
		||||
		if (scores[count] > average)
 | 
			
		||||
		{
 | 
			
		||||
				count2 = count2 + 1;
 | 
			
		||||
		}
 | 
			
		||||
}
 | 
			
		||||
document.write("The average is: " + average.toFixed(2) + "<br />");
 | 
			
		||||
document.write("The number above the average is: " + count2 + "<br />");
 | 
			
		||||
document.write("The number below the average is: " + (count1 - count2) + "<br />");
 | 
			
		||||
</script>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
</body></html>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user