CSC 160 - Computer Programming for Non-majors

Assignment #1: An exercise in JavaScript

Due Thurs., September 16, 2010

Given the program listed below, enter it using Notepad, save it as an HTML file run the program and and print it out. You will submit the listing as the assignment.

<html>
  <head>
    <title>CSC 160 Lab Exercise #1</title>
  </head>

  <body>
    <script type="text/javascript">

      // This program converts temperature in degree Fahrenheit
      // into degrees Celsius

    var  celsius, fahr;

    //Get the temperature in degrees Fahrenheit
    fahr = parseFloat(prompt("Enter a temperature in degree Fahrenheit  ?", 0));
    
    //Convert into Celsius and print it
    celsius = (fahr - 32)*5/9;
    alert(fahr + " degrees Fahrenheit is " + celsius 
		+ " degrees Celsius");

    </script>
  </body>
</html>

[Back to the Lab Assignment List]