Browse Source

删除 'TemperatureConverter.java'

pull/2/head
pangyaxuan 1 month ago
parent
commit
877089d100
  1. 26
      TemperatureConverter.java

26
TemperatureConverter.java

@ -1,26 +0,0 @@
import java.util.Scanner;
public class TemperatureConverter {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("=== 温度转换程序 ===");
System.out.print("请输入温度值:");
double value = sc.nextDouble();
System.out.print("请输入单位(C/F):");
String unit = sc.next();
if (unit.equalsIgnoreCase("C")) {
double f = value * 9 / 5.0 + 32;
System.out.printf("%.2f℃ = %.2f℉%n", value, f);
} else if (unit.equalsIgnoreCase("F")) {
double c = (value - 32) * 5 / 9.0;
System.out.printf("%.2f℉ = %.2f℃%n", value, c);
} else {
System.out.println("输入错误!请输入 C 或 F");
}
sc.close();
}
}
Loading…
Cancel
Save