📄 exercise2_1.java
字号:
import javax.swing.JOptionPane;
public class Exercise2_1 {
// Main method
public static void main(String[] args) {
// Enter a temperatur in Fahrenheit
String fahrenheitString = JOptionPane.showInputDialog(null,
"Enter a temperature in fahrenheit:",
"Exercise2_1 Input", JOptionPane.QUESTION_MESSAGE);
// Convert string to double
double fahrenheit = Double.parseDouble(fahrenheitString);
// Convert it to Celsius
double celsius = (5.0 / 9.0) * (fahrenheit - 32);
// Display the result
System.out.println("The temperature is " +
celsius + " in Celsius");
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -