• CSC 363 -  JavaScript Functions 
  • Due Date under Tasks List in Blackboard
  • 30 Points

Objectives:   The lab gives you practice in using javaScript built-in functions, such as parseFloat, as well as writing your own functions that receive parameters when called.

Implement the following functions:

A. Function Celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation:

C = 5.0/9.0 * (F-32)

B. Function Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculations:

F = 9.0/5.0*C+32

C.  Use these functions to write a script that enables the user to enter either a Fahrenheit or a Celsius temperature and displays the Celsius or Fahrenheit equivalent, respectively.

Your XHTML document should contain three buttons - one to initiate the conversion from Fahrenheit to Celsius and one to initiate the conversion from Celsius to Fahrenheit, and one to clear values of textboxes.  Screen Captures of solution web page follow:

Page when it first opens.

After entering 0 in the Celsius input box then clicking the Convert to Fahrenheit button

After pressing the Reset Button, both text boxes are cleared.

After entering 212 in the Fahrenheit input box then clicking the Convert to Celsius  button.

After pressing the Reset button, then entering 25.4  in the Celsius input box and  clicking the Convert to Fahrenheit b

 

Points will be allocated as follows:

Task Points Description
A 5
  • You have a Function Celsius which returns the Celsius equivalent of a Fahrenheit temperature, input.

B 5
  • Correctly working Function Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature.
C 2
  • Your document should contain two text boxes, each labeled, for input and output of  Fahrenheit and Centigrade temperature.
D 3
  • Your document should a button  that acts as an event handler to call the temperature conversion routine to take the text in the Celsius text box, convert it to Fahrenheit, then display it in the text box labeled Fahrenheit.
E 3
  • Another button will invoke an event handler  to take the text in the  Fahrenheit text box, convert it to  Celsius, then display it in the text box labeled Celsius.
F 3
  • The third button will cause the text in both  text boxes, to be cleared.
G 4 Your page is valid HTML 4.0.  That means:

There are a couple good articles from W3Schools that demonstrate these concepts.  These articles are about XHTML, but XHTML is not very different from HTML 4.01 so they give good advice.

  1. http://www.w3schools.com/xhtml/xhtml_html.asp?output=print
  2. http://www.w3schools.com/xhtml/xhtml_syntax.asp?output=print
  30 Total Points

Deliverables:

1.  Your name should be displayed in the title bar when your XHTML document is loaded.

2.  Place a link to this page on your CSC/CIS 363 course home page, index.html on your  profhicks server account

 

           

This page was last updated on  04/23/2009   by Linda M. Hicks