PL/SQL block for Fahrenheit to Celsius conversion

Q. Write a PL/SQL block to convert a temperature in Fahrenheit (F) to its equivalent in Celsius (C) and vice versa.

Answer:

Formula:
I) C = (F-32)*5/9
II) 9/5*C + 32

The above formulas are used in the following program to convert a temperature in Fahrenheit (F) to its equivalent in Celsius (C) and vice versa.

DECLARE F number:=&Fahrenheit;
C number:=&Celsius;
RESULT number;
BEGIN RESULT:=(F-32)*5/9;
dbms_output.put_line('Fahrenheit value entered '||F||' equal to celsius :'||' '||round(RESULT));
RESULT:=9/5*C+32;
dbms_output.put_line('Celsius value entered '||C||' equal to fahrenheit :'||' '||RESULT);
END;
/


Output:

fahrenheit to celsius