PTA-------L1-004 计算摄氏温度(Java语言)

    科技2022-07-13  109

    L1-004 计算摄氏温度

    给定一个华氏温度F,本题要求编写程序,计算对应的摄氏温度C。计算公式:C=5×(F−32)/9。题目保证输入与输出均在整型范围内。

    给定一个华氏温度F,本题要求编写程序,计算对应的摄氏温度C。计算公式:C=5×(F−32)/9。题目保证输入与输出均在整型范围内。

    import java.util.Scanner; /**L1-004 计算摄氏温度 给定一个华氏温度F,本题要求编写程序,计算对应的摄氏温度C。计算公式:C=5×(F−32)/9。题目保证输入与输出均在整型范围内。*/ public class PrintFah { public static void main(String args[]) { Scanner scan=new Scanner(System.in); //System.out.print("请输入F"); int F=scan.nextInt(); int C=5*(F-32)/9; System.out.print("Celsius = " + C); } } //其实最开始写的代码是下方的代码,不过PTA编译不通过,可能与题意不符,不过我觉得这个跟详细一些 public class PrintFah { public static void main(String args[]) { Scanner input=new Scanner(System.in); System.out.print("请输入华氏度F"); int F=input.nextInt(); int C=5*(F-32)/9; System.out.print("Celsius = " + C); } }

    效果图

    Processed: 0.025, SQL: 8