Homework 6 Due 11/30
1) Simple JavaScript Functions (10 pts)
1a) Adding 3 Numbers (5 pts)
Define a function add3 that accepts as arguments 3 numbers as strings and returns the value of the three numbers added together
1b) Find the area of a trapazoind (5 pts)
Define a function trapazoidArea the returns the area of a trapazoid given the length of the two bases and its height
The area of a trapazoid is given by the formula: \( A = \frac{a + b}{2} h \)
2) Finding Standard Devation (20 pts)
2a) Finding the Mean (5 pts)
Define a function mean that returns the average given an array of numbers
2b) Finding the deviations (5 pts)
Define a function deviations that takes two parameters, an array of numbers and the number to caluclate the deviation from
2c) Find the deviation (10 pts)
Define a function stdDev that takes an array of numbers, and calculates the std deviation using the above functions.
The algorithm for finding the standard deviation can be found on the
wikipedia page for standard deviation
3) Event Handling (35 pts)
For these two questions, you will add JavaScript to the HTML file provided
here.
3a) Find the maximum (20 pts)
In the website the HTML file above generates, there are 5 text boxes and a button. Write an event listner that allows the folowing:
- When the button is clicked, find the largest of the 5 numbers.
- Create a green outline around the box that contains the largest number
3b) Word Counter (15 pts)
In the website that the HTML file above generates, there is also a text area (the large text box).
Implement a word count event listener that continously updates the number of words
typed in the box and displays the number of words in the HTML element with id wordCount.
4) AJAX (35 pts)
4a) Animal Bingo (20pts)
Write JavaScript in the file
AnimalBingo.html that allows the user to click on a radio
button to generate an Animal Bingo sheet based on where they are taking a road trip. When
radio button is clicked, use AJAX to get the animals to place in the squares. The AJAX
request to
http://www.csee.umbc.edu/~bwilk1/Animals.php
will take one parameter
loc that is road trip location. It will return an array of
image locations.
4b) Converting Currency (15 pts)
Write JavaScript in the file
CurrencyConvertor.html.
There is one text box to enter a number
that represents the amount in dollars. Use AJAX to convert the amount to the appropriate
currency based on the button the user clicks on. The AJAX endpoint is
http://www.csee.umbc.edu/~bwilk1/Currency.php
and the parameters are
amt for the dollar amount, and
to that represents
the currency to convert to.
Submission
Along with your project, submit a README.txt with instructions on how to
run the code and what files will be generated.
submit cs331_bwilk1 hw6 hw6.js events.html AnimalBingo.html CurrencyConvertor.html