import java.util.Scanner;
public class CelsiusToFahrenheit {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入摄氏温度: ");
double celsius = scanner.nextDouble();
double fahrenheit = celsius * 9/5 + 32;
System.out.println("华氏温度为: " + fahrenheit);
}
}
此段代码公式为F C * 9/5 + 32.运行程序后,会提示用户输入摄氏温度,然后计算并打印出对应的华氏温度。