我正在用Java制作一个简单的温度转换程序,将华氏温度转换为摄氏温度.我的程序编译得很好,但无论我输入什么数字,它总是说Celsius是0.0!我能做错什么?这是我的完整代码:
import javax.swing.JOptionPane;
public class FahrenheitToCelsius {
public static void main(String[] args) {
double fahrenheit, celsius;
String input = JOptionPane.showInputDialog("Please enter the temperature in Fahrenheit:");
fahrenheit = Double.parseDouble(input.trim());
celsius = (5 / 9) * (fahrenheit - 32);
JOptionPane.showMessageDialog(null, "The temperature is " + celsius + " degrees celsius.");
}
}
Run Code Online (Sandbox Code Playgroud) 如果我在Java中创建一个只有一个实例变量的整数数组的简单类,那么对于默认构造函数有什么意义呢?我不想把它留空.