Computer Science I - Programming Assignment 2
Due Wednesday, October 21st
Summary
For this assignment you will be designing and testing a javaScript library that computes the following mathematical formulas:
-
The Quadratic Formula:
Given a quadratic equation:
-
The Discriminant function calculates the discriminant:
- The RealRoot1 function calculates the larger of the roots.
- The RealRoot2 function calculates the smaller of the roots.
-
The Area of a Circle: A = πr2
-
The Volume of a Sphere: V = 4/3 πr3
-
The application of the Pythagorean Theorem
to calculate the length of the hypotenuse of a right triangle given the lengths of the other two sides:
The functions must be implemented in a file called
formula.js, and the tests must be implemented in a file called
formula-test.html.
I have already implemented the
Discriminant function, and the skeletons of the remaining functions here:
formula.js.
I have also implemented a
RunTest function and the test for
Discriminant and
Sine here:
formula-test.html.
You must implement the remaining functions and tests yourself.
Do NOT change the names or parameters of any of the functions as I will be using my own files to test your functions and your tests.
Helpful Hints
- π is π in HTML and Math.PI in JavaScript.
- You may use the Math.sqrt and Math.pow built-in functions in your code.
Instructions for Handing In the Program
Please hand in the following:
- a printed copy of your completed formula.js and formula-test.html in class on the due date
- an electronic copy of these files via FileZilla in the handin folder in your home directory on the CS server.
Do not put your assignment in your html directory as that is publicly viewable.