temperature definitions and conversions


Temperature is given in degrees fahrenheit, degrees celsius, degrees kelvin

// f_to_c.java      compile    javac -cp . f_to_c.java
//                  execute    java  -cp . f_to_c fahrenheit computes celsius
//
// temperature   fahrenheit  celsius   kelvin  degrees
//               -459.67     -273.15     0.0     absolute zero
//                 32           0      273.15    water H2O freeze
//                212         100      373.15    water H2O boils
//               2750        1510     1783.15    some steel melts
// a water molecule having two hydrogen atoms and one oxygen atom
// pressure at 1 atmosphere for water measurements
// a copper wire at absolute zero has zero resistance, super conducting

f_to_c.java source code

public class f_to_c
{
  public f_to_c(double f)
  {
    double factor = (double)100/(double)(212-32);
    double c;
    System.out.println("f_to_c.java fahrenheit to celsius running");
    c = (f-32.0)*factor;
    System.out.println(f+" degrees fahrenheit = "+c+" degrees celsius");
  }

  public static void main (String[] args)
  {
    new f_to_c(Double.parseDouble(args[0]));
  }
} // end f_to_c

f_to_c_java.out output

f_to_c.java fahrenheit to celsius running
2750.0 degrees fahrenheit = 1510.0 degrees celsius

212.0 degrees fahrenheit = 100.0 degrees celsius

32.0 degrees fahrenheit = 0.0 degrees celsius

-459.67 degrees fahrenheit = -273.15 degrees celsius



f_to_k.java source code

f_to_k_java.out output

f_to_k.java fahrenheit to kelvin running
2750.0 degrees fahrenheit = 1783.15 degrees kelvin

212.0 degrees fahrenheit = 373.15 degrees kelvin

32.0 degrees fahrenheit = 273.15 degrees kelvin

-459.67 degrees fahrenheit = 0.0 degrees kelvin



c_to_f.java source code

c_to_f_java.out output

c_to_f.java celsius to fahrenheit running
1510.0 degrees celsius = 2750.0 degrees fahrenheit

100.0 degrees celsius = 212.0 degrees fahrenheit

0.0 degrees celsius = 32.0 degrees fahrenheit

-273.15 degrees celsius = -459.67  degrees fahrenheit



c_to_k.java source code

c_to_k_java.out output

c_to_k.java celsius to kelvin running
1510.0 degrees celsius = 1783.15 degrees kelvin

100.0 degrees celsius = 373.15 degrees kelvin

0.0 degrees celsius = 273.15 degrees kelvin

-273.15 degrees celsius = 0.0 degrees kelvin



k_to_f.java source code

k_to_f_java.out output

k_to_f.java kelvin to celsius running
1783.15 degrees kelvin = 2750.0 degrees fahrenheit

373.15 degrees kelvin = 212.0 degrees fahrenheit

273.15 degrees kelvin = 32.0 degrees fahrenheit

0.0 degrees kelvin = -459.66999999999996 degrees fahrenheit



k_to_c.java source code

k_to_c_java.out output

k_to_c.java kelvin to celsius running
1783.15 degrees kelvin = 1510.0 degrees celsius

373.15 degrees kelvin = 100.0 degrees celsius

273.15 degrees kelvin = 0.0 degrees celsius

0.0 degrees kelvin = -273.15 degrees celsius


f_to_c.py3 source code

# f_to_c.py3   read degrees fahrenheit and print degrees celsius
from sys import argv
# f_to_c.py3       compile    javac -cp . f_to_c.java
#                  execute    java  -cp . f_to_c fahrenheit returns celsius
# temperature   fahrenheit  celsius   kelvin  degrees
#               -459.67     -273.15     0.0     absolute zero
#                 32           0      273.15    water H2O freeze
#                212         100      373.15    water H2O boils
#               2750        1510     1783.15    some steel melts
# a water molecule having two hydrogen atoms and one oxygen atom
# a copper wire at absolute zero has zero resistance, super conducting

def f_to_c(f):
  print("f_to_c.py3 converting fahrenheit to celsius")
  fval = float(f)
  factor = 100.0/(212.0-32.0);
  c = (fval-32.0)*factor;
  print(fval," degrees fahrenheit = ",c," degrees celsius");

# end f_to_c

if __name__=='__main__':
  if len(argv) > 1:
    f_to_c(argv[1]) # read fahrenheit degrees

  else :
    f_to_c("212")


# end f_to_c.py3

f_to_c_py3.out output

f_to_c.py3 converting fahrenheit to celsius
32.0  degrees fahrenheit =  0.0  degrees celsius

etc...

  Last updated 6/24/2020