LAB EXERCISE - 6.1 FUN
Assignment:
1. The two temperature scales used in the United States are Celsius and Fahrenheit. The mathematical relationship between the two scales is:
C = 5/9 (F - 32)
Write two functions, 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
2. Write a function which takes in the radius of a sphere and returns its volume. The formula is:
V = 4/3 - r3
You are encouraged to use a constant for the value of _.
3. Write a function which returns the hypotenuse of a right triangle given the input of the two smaller sides. Use the Pythagorean theorem:
a2 + b2 = c2
Instructions:
1. Round off all floating point values to two decimal places (0.01).
2. Remember to write function prototypes for all four of your functions.
3. You can use the following format of a cout statement to test your program:
cout << "212 degrees F ---> " << fToC (212) << " degrees C" << endl;
function main could be written using only 11 function calls.
4. Use the following values to test your functions:
Fahrenheit to Celsius: 212oF, 98.6oF, 10oF
Celsius to Fahrenheit: -15oC, 0oC, 70oC
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
5. Template- fill in missing parts: Note that functions are required on this and all future programs.
//Your Name Lesson 6.1 P#9 //Function Lab Exercise //Template- fill in missing parts:
int intro( ) |