Lexington High School Mathematics Math Dept. Front Page  | Student Links  | Family Links 
Introduction to C++, Kevin Kelly Kelly Front Page  | C++ Course Guide | C++ Assignments | C++ Info

Assignment 9: Temperature conversion function

due Wednesday 3/6

(Make sure your program is labeled as Assignment 9.)

Your assignment is to rewrite your temperature conversion program (from Assignment 4) so that the computation is performed by a function called FtoC. This function should take a Fahrenheit temperature as a parameter (an input), and return a Celsius temperature.

While the computation will be done in the FtoC function, the input and output should still occur in the main part of the program. In other words, main should not include any arithmetic, and FtoC should not contain any cin or cout statements.

Run your program three times with these test values: 98 degrees, 5.5 degrees, -40 degrees.




Extensions

For 3 pts.: Also write a function CtoF that converts from Celsius to Fahrenheit. To test this function, convert the results of your three FtoC test runs back into Fahrenheit.

For 10 pts.: Besides the above, write a separate program that does the following:

This program must use FtoC and/or CtoF functions identical to those in your first program. Test the program enough times to show that it handles each kind of situation correctly.