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 16: Temperature conversion with menu

due Monday 3/25

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

Summary of the assignment: Write a temperature conversion program that gives the user a choice of which direction to convert (from F to C or from C to F).

User interface: Begin by presenting the user with a menu of options. If the user types C, prompt for a Celsius temperature and convert it to Fahrenheit. If the user types F, prompt for a Fahrenheit temperature and convert it to Celsius. If the user types anything else, just exit without doing any conversion.

Programming specifics: Please store the user's choice in a char variable. Allow the user to type either upper or lower case (accept either C or c). The temperature calculations must be done in two functions FtoC and CtoF, not in the main program. (You can reuse the function or functions that you've already written for Assignment 9.)




Extensions

For 5 pts.: Make the program return to the menu repeatedly so the user can convert more temperatures, stopping only when they enter a letter other than F or C. Hint: Use one of the looping constructions described in Chapter 7.

For 10 pts.: Besides writing a program that works exactly as described above, also hand in a second program that converts among three temperature scales: Fahrenheit, Celsius, and Kelvin. Redesign the user interface so that it begins by asking two questions: (1) from which scale to convert, (2) to which scale to convert.