Question: For Programming in Java: Write a program to input a character and a number. If the char is F or 'f', convert the number to

For Programming in Java:

Write a program to input a character and a number. If the char is F or 'f', convert the number to Celsius using the formula below. If the char is C or 'c', convert the number to Fahrenheit. If the char is not F, 'f', C,or 'c', output error message.

Formula for the temperature conversion (pay attention to int and double): C = (F -32) * 5/9 F = (C * 9/5) +32

(1) Input and out a character and a number

Enter a character and a number: F 47.5

You entered: F and 47.5

(2) If the character is F or 'f', convert the number to Celsius (format the output to 1 decimer pt)

Enter a character and a number: F 47.5

You entered: F and 47.5

47.5 F = 8.6 C

(3) If the character is C or 'c', convert the number to Fahrenheit (format the output to 1 decimer pt)

Enter a character and a number: c 47.5

You entered: c and 47.5

47.5 C = 117.5 F

(4) If the char is not F, 'f', C, or 'c', output error message.

Enter a character and a number: a 47.5

You entered: a and 47.5

a is invalid input

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!