Lab 12 - It 130

  1. Study the code for dice3.html and dice4.html.You can find the code at the course homepage. Modify dice3 so that it first displays and alert box if you roll doubles. an alert box if you roll
  2. Study dice5.html. Modify dice5.html to display two die when the button is pressed.
  3. Do this problem from the book.

    The following piece of code translates the formula into javascript.

    if(windSpeed <= 3) {
       windChill = temperature;
    }
    else{ 
       windChill = 35.74 + 0.6215 * temperature + 
                    (0.4275 * temperature - 35.75) * Math.pow(windSpeed, 0.16);
        }
    
    

    Where temperature and windSpeed are values entered by the user.

  4. Copy and paste the code. Run it several times and study the code. Enter negative numbers and enter an alpha character 's'
  5. <html> <head> <title>Validate</title> <script> function validate(input) { if (input < 0 || isNaN(input) ) { return false; } else { return true; } } function compute() { var input = document.frmSqrt.txtNum.value; input = parseFloat(input); if( validate(input )) { var result = Math.sqrt(input); document.frmSqrt.txtSqrt.value = result; } else { alert("Must enter a positive number, you entered " + input); document.frmSqrt.txtNum.value = ""; } } </script> </head> <body> <form name="frmSqrt"> <p>Enter Positive Number &nbsp; <input type="text" name="txtNum" value=""/> </p> <p>Square Root: <input type="text" name="txtSqrt"/></p> <p><input type="button" value="Find Square Root" onclick="compute();""/> </form> </body> </html>
  6. Add a validation to temperature3. For example if the user enters the correct input do the computation else print an alert.
  7. Study dice5.html. Modify dice5.html to display two die when the button is pressed.
  8. Work on Project