**COMPUTER SCIENCE SET 1 6W4**

**1)
****Print and
turn in each program as it is complete.
Put the date and time submitted.**

**2)
****Document the
contract and purpose for each program. **

**3)
****The examples
can be done with a calculator, so I do not need to see this. **

**4)
****But, make
sure you check and record for your tests.**

**5)
****Test with
data used in your examples. **

__PROGRAM 1 - POWERS__

- Write a function that finds the square of a number.
- Write a function that find the cube of a number reusing the square function.
- Write a function that raises a number to the fourth power reusing the only functions calls.
- Write a function that raises a number to the fifth power reusing a combination of the above functions.
- Write a function that raises a number to the sixth power reusing the above.
- Write 4 more functions that raises a number the Nth power. You determine the power.

- Test with the same 2 numbers for each function.
- Each
function should have 2 function calls, ie:
(cube 2) = 8 (cube 3) = 27

__PROGRAM 2 - RATIOS__

v Declare constants for the following: (CONSTANT IDENTIFIERS SHOULD BE IN ALL CAPS)

§ 12 inches Function: feet->inches

§ 3 feet Function: yards->feet

§ 1760 yards Function: miles-> yards

§ 3 teaspoons Function: tablespoon->teaspoon

§
16 tablespoons *You** get the idea. Feel free to create your own program name*

§ 8 ounces

§ 4 cups

§ 4 quarts

v Write a program that will determine number of inches in a given number of miles reusing functions.

v Write a program that will determine the number of teaspoons in a gallon given the number of teaspoons reusing function.

v Find another set of conversions and write a series of functions for that.

v HINT: Always test with 1 and then another easy number.

v
HINT: The function itself only contains
constants and variables.

__PROGRAM 3 – RATE __

v
__Specific Problem__

§
This is the Amusement Park Graphing Linear
Function scenario from worksheet and Quiz.

§
Read those directions to understand the specific
problem.

v
__General Problem__

§ Write a function that will determine the distance from a location at any point in time until arrival. The distance from the location and the rate you are driving are constants. The program consumes the minutes you have driven.

§ Declare a CONSTANT for the distance from the location.

§ Declare a CONSTANT for the rate you are driving.

§ Create 2 new scenarios to use as examples

§
Test with data from the worksheet and quiz. *You have already done the examples.*

§ Test with your examples.

v Note:

§ Assume that the time is less than or equal to the amount needed for arrival:

§ 0 < Time < Distance/Rate

§
Formula is D = RT so T = D/R