# Week 4 Exercises (ICM)

Exercises 7-8 and 8-5

7-8: Write a function that takes one argument-F for Fahrenheit-and computes the result of the following equation (converting the temperature to Celsius). C = (F – 32) * (5 / 9)

Solution: Processing Code

8-5: Rewrite the Example 5-9 (Gravity) using objects. Include two instances of a “Ball” (or whatever you call it) object.

Solution: Processing Code

For 7-8, “float c = (5/9);” returns 0.0. I got around this by using modulo and multiplying by .11, “float c = (5 % 9) * (.11) ;”. The other (proper) solution would be to change 5 & 9 to 5.0 and 9.0, to get more accurate results. The example provided above uses modulo.

## Leave a Reply