Newer
Older
labs / tiddlers / content / review / java_exercises / _Review_Temperature Converter.md
@Mark George Mark George on 15 Jul 2021 769 bytes Add review exercises

Write a Java class that has two public static methods:

  • The first method should convert a decimal number argument from Celsius to Fahrenheit.

  • The second method should covert a decimal number argument from Fahrenheit to Celsius.

Test the methods by copying and adapting the code for the console menu that you created earlier to allow the user to choose which conversion they wish to perform and then enter the value that they want to convert.

The following are the equations for the conversions:

<$latex text="^{\circ}F=\left(\frac{9}{5}\ ^{\circ}C\right) + 32" />

<$latex text="^{\circ}C=\frac{5}{9}\left(^{\circ}F - 32\right)" />

FYI: <$latex text="32^{\circ}C = 89.6^{\circ}F" /> and <$latex text="68^{\circ}F=20^{\circ}C"/>