All pastes #391445 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-12 04:15 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
var whichGameWon
        
        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:")
 
margin = 0
//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>")
        }
 
        if (homescore > awayscore)
        {
                x = homescore - awayscore
        }
        if (homescore < awayscore )
        {
                x = awayscore - homescore
        }
             if (x > margin) //if margin this game > previously stored margin
        {
  
               margin = x //update margin to store the highest margin found so far
              
               whichGameWon = whichGameWon + 1
               }
                
        count = count +1
}
 
 
output("Highest margin of victory:" + x + "pts (<i>" + hometeam + "</i> vs. <i>" + awayteam + "</i>)")  
output("<br>The game with the highest margin was game " + whichGameWon)
 
</script>
<body>
</html>