Question: (Java) Java selection structure. Write a Java program that reads in a temperature in either degrees Fahrenheit, Celsius, or Kelvin and converts the temperature to

(Java) Java selection structure.

Write a Java program that reads in a temperature in either degrees Fahrenheit, Celsius, or Kelvin and converts the temperature to the other two formats. Your program will ask for a single character representing the degree to be converted (F, C, K for the 3 types of measurements) and a number representing the temperature. If the input temperature code is not one of F, C, or K, issue an error message and end the code. If the input temperature value is not within -700 to 700 degrees, inclusive, issue an error message and end the code.

Tempature Conversion:

C = (F - 32) * 5/9 K = (F + 459.67) * 5/9 F = C * 9/5 + 32 K = (9/5 * C + 491.67) * 5/9 F = 9/5 * K 459.67 C = (491.67 9/5 * K) * 5 / 9

SAMPLE RUN:

Enter the degree conversion code: X INVALID code Enter the degree conversion code: F Enter the temperature value in degrees Fahrenheit: 900 INVALID value for temperature

Enter the degree conversion code: F Enter the temperature value in degrees Fahrenheit: 100 Temperature in degrees Celsius: 37.77 Celsius Temperature in degrees Kelvin: 310.92 Kelvin

Enter the degree conversion code: K Enter the temperature value in degrees Kelvin: 100 Temperature in degrees Celsius: -173.15 Celsius Temperature in degrees Kelvin: -279.67 Fahrenheit

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!