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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started