HW5 - Functions


Part 1

Create a webpage that contains a script that will use a function circleArea to prompt the user through a form input text box for the radius of a circle and to calculate and then print the area of the circle within another form input box. Access the function to calculate the circle's radius by using a form button.

Part 2

Create a webpage 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.

Part 3

Create a webpage that contains a script containing a function that inputs a student's average and returns 4 if the student's average is 90-100, 3 if the average is 80-89, 2 if the average is 70-79, 1 if the average is 60-69, 0 if the average is 0-60. If the average is NOT between 0 and 100, display "invalid input". The function should prompt the user for the student's average, validate the average, and then if valid, call a 2nd function to determine and return 0, 1, 2, 3, or 4 depending on the average.

Part 4

Create a webpage that contains a function squareofasterisks that displays a solid square of asterisks whose side is specified in integer parameter side. For example, if the side is 4, the function displays
* * * *
* * * *
* * * *
* * * *

Incorporate this function into a script that reads an integer value for side from a form input text box and performs the drawing with the squareofasterisks function.

Extra Credit

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. It should then display a question such as: How much is 6 times 7?



back

Hosted by www.Geocities.ws

1