(Convert Celsius to Fahrenheit) Write a program that reads a Celsius degree in a double value from the console, then converts it to Fahrenheit and displays the result. The formula for the conversion is as follows:
Fahrenheit = (9 / 5) * Celsius + 32
Hint: In Java, 9 / 5 is 1, but 9.0 / 5 is 1.8.
Solution
OUTPUT
In this program the background knowledge which we have to acquire to solve this program is using:
fahrenheit = 9.0 / 5 * celsius + 32
Note: 9.0 is a double number.
In java there are Rules of Operator Precedence. And the arithmetic operations are preformed according to it.
Note: As System.out.println(); is used, therefore the value of Area and Perimeter gets printed in the new line.
If you have any doubts or questions, please let me know.