Make your own free website on Tripod.com
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>

<!- made to be displayed in the main frame of Lab6.html ->

<HEAD>
<TITLE>Exercise 8.18</TITLE>

<SCRIPT LANGUAGE = "JavaScript">
   var firstNumber,   // first string entered by user
       secondNumber,  // second string entered by user
       thirdNumber,  // third string entered by user
       number1,       // first number
       number2,       // second number
       number3,       // third number
       result;           // result of number1 and number2

   document.writeln( "<H2>Exercise 8.18</H2>" );

   // read in first number from user as a string
   firstNumber = window.prompt( "Enter first integer", "0" );

   // read in second number from user as a string
   secondNumber = window.prompt( "Enter second integer", "0" );

   // read in third number from user as a string
   thirdNumber = window.prompt( "Enter third integer", "0" );

   // convert numbers from strings to integers
   number1 = parseInt( firstNumber ); 
   number2 = parseInt( secondNumber );
   number3 = parseInt( thirdNumber );

   // display the numbers
   document.writeln( "<H1>You entered " + number1 + ",  " + number2 + 
                                  " and " + number3 + "</H1>" );

   // add the numbers
   result = number1 + number2 + number3;

   // display the results
   window.alert( "The sum is " + result );

   // Find average of the numbers
   result = (number1 + number2 + number3 )/ 3;

   // display the results
   window.alert( "The average is " + result );

   // Multiply the numbers
   result = number1 * number2 * number3;

   // display the results
   window.alert( "The poduct is " + result );
  
    // display largest and smallest
    if (number1>number2)
  {
      largest = number1;
    smallest = number2;
  }
  else
  {
    largest = number2;
    smallest = number1;
  }
  if (number3>largest)
    largest=number3;
  else if (number3<smallest)
    smallest=number3;
  window.alert( "The smallest number is "+smallest );
  window.alert( "The largest number is "+largest );
</SCRIPT>

</HEAD>
<BODY>
<P><b><-- Click on the lab you want to run.</b></P>

<a href="8_18src.html">View Source</a>

</BODY>
</HTML>