meta charsetutf 8 script type textjavascript var input1 windowprompt Enter

Meta charsetutf 8 script type textjavascript var

This preview shows page 9 - 13 out of 32 pages.

  <meta charset="utf-8" />  <script type = "text/javascript">     var input1 = window.prompt( "Enter first number", "0" );     var input2 = window.prompt( "Enter second number", "0" );     var input3 = window.prompt( "Enter third number", "0" );     var value1 = parseFloat( input1 );     var value2 = parseFloat( input2 );     var value3 = parseFloat( input3 );     var maxValue = maximum( value1, value2, value3 );     document.writeln( "First number: " + value1 +        "<br />Second number: " + value2 +        "<br />Third number: " + value3 +        "<br />Maximum is: " + maxValue );     // maximum method definition (called from line 25)     function maximum( x, y, z ) {                                                 return Math.max( x, Math.max( y, z ) );     }                                           </script></head></html>
Background image
09a - 10Random-Number GenerationnRandom-number generation introduces element of chancenMath.randomvar randomValue = Math.random();nFloating point value between 0 and 1nAdjust range by scaling and shiftingnMath.floorAlways round downMath.floor( 1 + Math.random() * 6 )COMP-1536 & ACIT-1620
Background image
09a - 11RollDie.htmlCOMP-1536 & ACIT-1620<!DOCTYPE HTML><html lang="en"><head><title>Roll a Six-Sided Die 6000 Times</title>  <meta charset="utf-8" /><script type = "text/javascript">   var frequency1 = 0, frequency2 = 0, frequency3 = 0, frequency4 = 0, frequency5 = 0, frequency6 = 0, face;   for ( var roll = 1; roll <= 6000; ++roll ) {        face = Math.floor( 1 + Math.random() * 6 );      switch ( face ) {         case 1: ++frequency1; break;         case 2: ++frequency2; break;         case 3: ++frequency3; break;         case 4: ++frequency4; break;         case 5: ++frequency5; break;         case 6: ++frequency6; break;      }   }   document.writeln( "<table border='1' width='50%'>" );   document.writeln( "<th>Face</th><th>Frequency</th>" );   document.writeln( "<tr><td>1</td><td>" + frequency1 + "</td></tr>" );   document.writeln( "<tr><td>2</td><td>" + frequency2 + "</td></tr>" );   document.writeln( "<tr><td>3</td><td>" + frequency3 + "</td></tr>" );   document.writeln( "<tr><td>4</td><td>" + frequency4 + "</td></tr>" );   document.writeln( "<tr><td>5</td><td>" + frequency5 + "</td></tr>" );   document.writeln( "<tr><td>6</td><td>" + frequency6 + "</td></tr></table>" );</script></head></html>
Background image
09a - 12RandomPicture.htmlCOMP-1536 & ACIT-1620<!DOCTYPE HTML><html lang="en"><head><title>Random Image Generator</title><meta charset="utf-8" /> <script type = "text/javascript">   function loadPicture() {    var img = new Image();    
Background image
Image of page 13

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture