Question: Using While loops in Java to allow the user to enter many temperatures and convert a temperature given in degrees from either Celsius to Fahrenheit

Using While loops in Java to allow the user to enter many temperatures and convert a temperature given in degrees from either Celsius to Fahrenheit or Fahrenheit to Celsius. Use the following formulas:

DegreesC = 5(DegreesF 32)/9

DegreesF=(9(DegreesC)/5) + 32)

Prompt the user for a temperature and either a C or c for Celsius or an F or f for Fahrenheit. Convert the temperature to Fahrenheit if either C or c is entered (meaning the user gave you the temperature in Celsius), or to Celsius if either f or F is entered (because the user gave you the temperature in Fahrenheit). Display the temperature with at most two places after the decimal point. (Convert whatever temperature the user gives you, even if it is a very high positive number or a very low negative one).

. For example, the input could be:

c 67.3

F 200

C 56.6

f 19.44

q //either q or Q will cause the program to end

I did it by using If statement for one input. Now I need help to do it by using While Loop for many inputs.

Thanks.

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!