所以我正在寫一個程序,給出每個輸入x秒鐘的分鐘數...現在的問題是,一旦我輸入第一個值,它會要求另一個值並將其分開....並且另一個價值......另一個價值......等等......我怎樣才能得到它只給我一個價值,並完成一個價值而不是永無止境的事物?重複JOptionPane彈出?
import javax.swing.JOptionPane;
class TimeCalculator {
public static void main(String[] args) {
double seconds;
String input;
input = JOptionPane.showInputDialog("Enter any number of seconds");
seconds = Double.parseDouble(input);
if (seconds >= 60);
JOptionPane.showInputDialog(null, "There are " + (seconds/60) + " minutes in " + seconds + " seconds.");
if (seconds >= 3600);
JOptionPane.showInputDialog(null, "There are " + (seconds/60) + " minutes in " + seconds + " seconds.");
if (seconds >= 86400);
JOptionPane.showInputDialog(null, "There are " + (seconds/60) + " minutes in " + seconds + " seconds.");
System.exit(0);
}
}
「'if(seconds> = 60);'」你確定這是正確的嗎? – 2016-09-28 18:09:30
使用'JOptionPane.showMessageDialog()'消息。 https://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html – 2016-09-28 18:12:45