also schreibe ich ein Programm, das die Anzahl der Minuten für jede Eingabe von x Sekunden gibt ... jetzt ist das Problem, dass, sobald ich den ersten Wert eintippe, fragt er nach einem anderen Wert und teilt das .... und ein anderer Wert ... und noch ein ... und so weiter ... wie kann ich erreichen, dass es mir nur einen Wert gibt und mit diesem einen Wert endet, anstatt mit einer unendlichen Sache?Wiederholtes JOptionPane-Popup?
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 (Sekunden> = 60); '" Sind Sie sicher, dass das korrekt ist? –
Verwenden Sie 'JOptionPane.showMessageDialog()' für die Nachricht. https://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html –