Write a Java program that converts temperature from Fahrenheit to Celsius and vice versa. The program will accept a number (temperature) and a temperature unit designation (i.e., character F or C) from the user, and then convert the temperature into the other unit system. The program will echo the input as part of the final conversion output. The temperature units should be printed in full (Fahrenheit or Celsius). Your program should use real numbers—not integers—for both input and output. Formula: T(F) = (T(C) * 9 / 5) + 32 T(C) = (T(F) − 32 ) * 5 / 9 Sample Run: This program converts Temperatures from Fahrenheit to Celsius and vice versa. Please enter your temperature: 32 Please enter the units (F/C): F A temperature of 32 degrees Fahrenheit is equivalent to 0 degrees Celsius. Do you wish another conversion? (Y/N): Y Please enter your temperature: 100 Please enter the units (F/C): C A temperature of 100 degrees Celsius is equivalent to 212 degrees Fahrenheit. Do you wish another conversion? (Y/N): N Thank you. Goodbye. There is no reason to accept only capital letters for F, C, Y or N. You should be able to accept either upper- or lowercase letters. You can exit the program either when an explicit N or n is read or, alternatively, when anything except an explicit Y or y is input. The choice is yours.
Write a Java
The program will accept a number (temperature) and a temperature unit designation (i.e., character F or C) from the user, and then convert the temperature into the other unit system. The program will echo the input as part of the final conversion output. The temperature units should be printed in full (Fahrenheit or Celsius). Your program should use real numbers—not integers—for both input and output.
Formula:
T(F) = (T(C) * 9 / 5) + 32
T(C) = (T(F) − 32 ) * 5 / 9
Sample Run:
There is no reason to accept only capital letters for F, C, Y or N. You should be able to accept either upper- or lowercase letters.
You can exit the program either when an explicit N or n is read or, alternatively, when anything except an explicit Y or y is input. The choice is yours.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images