All pastes #391441 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-03-12 04:10 UTC
rendered paste body
<html>
<head>
<title>Assignment 4 - Basketball Program</title>
<script language="javascript" src="http://www.student.cs.uwaterloo.ca/~cs100/cs100.js"></script>
<script language="javascript">

	//Simple function to output the results of a game in a simple table

	
</script>

</head>
<body>
<br>

<script language="javascript">
	
	var date
	var hometeam
	var awayteam
	var homescore
	var awayscore
	var number // number of games played and when the loop will be cut off
	var margin // highest margin of victory in the games played
	var x // part of margin of victory
	
	date = inputString ("Please input current date. (M/D/Y)") // obtain date
	
	output("<b>Basketball Results for " + date + "</b><br><br>")

	number = inputNum("Enter number of games played:")

//start loop
count = 0
for (;;)
{
	if(count == number) break
	{
	hometeam = inputString ("Enter name of home team:")
	homescore = inputNum ("Enter the score of the home team:")
	awayteam = inputString ("Enter name of away team:")
	awayscore = inputNum ("Enter the score of the away team:")

	output(" " + hometeam + " - " + homescore + "<br>")
	
	output(" " + awayteam + " - " + awayscore + "<br><br>")
	}
	
	margin = x

	if (homescore > awayscore)
	{
		x = homescore - awayscore
	}
	if (homescore < awayscore )
	{
		x = awayscore - homescore
	}
	     if (x > margin) 
	{ //if (margin this game) > (previously stored margin) then...
  
 		margin = x //update margin to store the highest margin found so far
  		
 		n++ //increase n by 1     
 		}
 		 
	count = count +1
}


output("Highest margin of victory:" + x + "pts (<i>" + hometeam + "</i> vs. <i>" + awayteam + "</i>)")	

</script>
<body>
</html>