Homework 5 - FUNCTIONS
Part 1 Create a webpage that contains a script that will use a function to input via a form input text box for the radius of a circle and to calculate and then print the area and the circumference of the circle within two other form text input boxes. Access the function to calculate the circle's radius and circumference by using a form button.
Part 2 Create a webpage using form text boxes that:
a) contains the function celsius, that returns the Celsius equivalent of a Fahrenheit temperature, using the calculation:
C = 5/9 * (F - 32)
b) contains the function fahrenheit that returns the Fahrenheit equivalent of a Celsius temperature, using the calculation:
F = 9/5 * 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.
Your XHTML document should contain two form buttons - one to initiate the conversion from Fahrenheit to Celsius and one to initiate the conversion from Celsius to Fahrenheit.
Part 3 Create a webpage containing a script that will determine whether a department-store customer has exceeded the credit limit on their charge account.
For input, the following facts should be available in form input text boxes:
a) Account number
b) Balance at the beginning of the month
c) Total of all items charged by this customer this month
d) Total of all credits applied to this customer's account this month
e) Allowed credit limit
Validate whether the account number has been entered and that the amount items are numeric.
Part 4 Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. Use Math.random to produce two positive one-digit integers (0-9). It should then display a question such as:
How much is 6 times 7?
The student then types the answer into a text field. Your program checks the student's answer. If it is correct, display the string "Very good!" in an alert, and then prompt the user to see whether they wish to continue. If so, then generate a new question. If not, then exit the script.
If the answer to the multiplication question is wrong, display the string "No. Please try again." in an alert, and let the student try the same question again repeatedly until the student finally gets it right. A separate function should be used to generate each new question. This function should be called once when the script begins execution and each time the user answers the question correctly.
Extra Credit Write a script to simulate the game of craps using Math.random.

HOME