Question: Write a program that takes a temperature in Fahrenheit or Celsius from standard input, converts it from one scale to the other, and then prints

 Write a program that takes a temperature in Fahrenheit or Celsius

Write a program that takes a temperature in Fahrenheit or Celsius from standard input, converts it from one scale to the other, and then prints the result to standard output. At the start of the program, prompt the user to input a temperature by printing the string "Convert temperature. Input DEG UNIT(F/C): ". If the user inputs an invalid unit, then print "The unit must be either 'F' or 'C' . ". For the purposes of this program, assume that lowercase 'f ' and 'c ' are invalid units. If the user inputs the temperature in degrees Fahrenheit ('F'), then display the temperature in Celsius; if the user inputs the temperature in degrees Celsius ('C'), then display the temperature in Fahrenheit. Use format %. 2f for your numerical output. As part of your program, you must make two functions: one that converts Fahrenheit to Celsius and one that converts Celsius to Fahrenheit. You can use the following function prototypes: float cel2fahr(float cel); float fahr2cel(float fahr); Example input/output pairs (excluding the prompt) are provided below: Input: 32 F; Output: 0.00 C Input: -11 F; Output: -23.89 C Input: 20.5 C; Output: 68.90 F Input: 100 c; Output: The unit must be either 'F' or 'C

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!