首页javafloatJava Data Type - 如何用浮点数进行华氏与摄氏的转换

Java Data Type - 如何用浮点数进行华氏与摄氏的转换

我们想知道如何用浮点数进行华氏与摄氏的转换。
public class Main {
  public static void main(String[] arguments) {
    float fah = 86;
    System.out.println(fah + " degrees Fahrenheit is ...");
    fah = fah - 32;
    fah = fah / 9;
    fah = fah * 5;
    System.out.println(fah + " degrees Celsius\n");

    float cel = 33;
    System.out.println(cel + " degrees Celsius is ...");
    cel = cel * 9;
    cel = cel / 5;
    cel = cel + 32;
    System.out.println(cel + " degrees Fahrenheit");
  }
}