| |
L.A.7.1 - Fun | page 8 of 10 |
Assignment:
The two temperature scales used in the United States are Celsius and Fahrenheit. The mathematical relationship between the two scales is:

Write two methods, fToC and cToF , which convert temperatures from one scale to another. For example, a call of fToC will return the equivalent Celsius temperature for a given Fahrenheit temperature.
Celsius = fToC(100); // Celsius now stores 37.8
Write a method that takes in the radius of a sphere and returns its volume. The formula is:

You are encouraged to use a constant for the value of
Write a method that returns the hypotenuse of a right triangle given the input of the two smaller sides. Use the Pythagorean theorem:

Instructions:
Format all floating point values to two decimal places (0.01).
You can use the following format of an output statement to test your program:
System.out.println("212 F --> " + Format.left(fToC(212), 10, 2));
the main method could be written using only 11 method calls.
Use the following values to test your functions:
Fahrenheit to Celsius: 212°F, 98.6°F, 10°F
Celsius to Fahrenheit: -15°C, 0°C, 70°C
Volume of a sphere, radius of: 1.0, 2.25, 7.50
Hypotenuse calculations: sides of 3.0 and 4.0, sides of 6.75 and 12.31
|