8 changed files with 3 additions and 62 deletions
@ -1,26 +0,0 @@ |
|||
温度转换程序使用说明 |
|||
|
|||
|
|||
|
|||
编译命令 |
|||
|
|||
|
|||
|
|||
javac TemperatureConverter.java |
|||
|
|||
|
|||
|
|||
运行命令 |
|||
|
|||
|
|||
|
|||
java TemperatureConverter |
|||
|
|||
|
|||
|
|||
程序功能 |
|||
|
|||
|
|||
|
|||
实现摄氏温度与华氏温度的双向转换 |
|||
|
|||
@ -1,2 +0,0 @@ |
|||
# java |
|||
|
|||
Binary file not shown.
@ -1,29 +0,0 @@ |
|||
/** |
|||
* 温度转换程序 |
|||
* 功能:摄氏温度与华氏温度互相转换 |
|||
*/ |
|||
public class TemperatureConverter { |
|||
/** |
|||
* 摄氏转华氏 |
|||
* 公式:F = C * 9 / 5 + 32 |
|||
*/ |
|||
public static double celsiusToFahrenheit(double c) { |
|||
return c * 9.0 / 5.0 + 32; |
|||
} |
|||
/** |
|||
* 华氏转摄氏 |
|||
* 公式:C = (F - 32) * 5 / 9 |
|||
*/ |
|||
public static double fahrenheitToCelsius(double f) { |
|||
return (f - 32) * 5.0 / 9.0; |
|||
} |
|||
public static void main(String[] args) { |
|||
// 测试用例
|
|||
double c = 36.6; |
|||
double f = celsiusToFahrenheit(c); |
|||
System.out.printf("%.2f 摄氏度 = %.2f 华氏度\n", c, f); |
|||
double f2 = 98.6; |
|||
double c2 = fahrenheitToCelsius(f2); |
|||
System.out.printf("%.2f 华氏度 = %.2f 摄氏度\n", f2, c2); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
1.利用AI学习Java语言的基础知识 |
|||
2.让AI帮助修改代码 |
|||
3.求助AI用git提交作业 |
|||
@ -1,5 +0,0 @@ |
|||
public class Hello World{ |
|||
public static void main(String[] args) { |
|||
System.out.println(“Hello World”); |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 279 KiB |
Loading…
Reference in new issue