集册 Java实例教程 使用数字文字计算华氏温度和摄氏温度

使用数字文字计算华氏温度和摄氏温度

欢马劈雪     最近更新时间:2020-01-02 10:19:05

677
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用数字文字计算华氏温度和摄氏温度

public class Main {

    public static void main(String[] arguments) {

        float fah = 86;

        System.out.println(fah + " degrees Fahrenheit is ...");// 来 自 时代Java公众号 - N o w J a  v a . c o m

        // To convert Fahrenheit into Celsius begin by subtracting 32

        fah = fah - 32;

        // Divide the answer by 9

        fah = fah / 9;

        // Multiply that answer by 5

        fah = fah * 5;

        System.out.println(fah + " degrees Celsius\n");


        float cel = 33;

        System.out.println(cel + " degrees Celsius is ...");

        // To convert Celsius into Fahrenheit begin by multiplying by 9

        cel = cel * 9;

        cel = cel / 5; 
展开阅读全文