Fehlermeldung: )erwartete, und "keine Aussage" ;erwartet
Im völlig neuen Programmierung in java und folgenden einige grundlegende tutorials für mein selbst.
Im, der versucht zu lösen, eine Aufgabe welche mir sagt, um ein kleines Programm, wo der Benutzer eingibt in eine amonunt von Sekunden. Das Programm soll dann zurück, wie viele Stunden, Minuten und Sekunden dies ist. I cant get ridd der Fehlermeldungen. Kann jemand mir bitte helfen?
Mein code ist der folgende
import javax.swing.JOptionPane;
public class Time2
{
public static void main( String args[] )
{
//Defining types of data:
String secondstring;
int minutes;
int seconds;
int hours;
int seconds1;
int seconds2;
//Making inputwindow and initializing the variable sekondstring:
secondstring = JOptionPane.showInputDialog( "Type in seconds!" );
//Converting secondstring to type int:
seconds = Integer.parseInt( secondstring );
//Initializing the variables seconds, minutes and hour:
hours = seconds / 3600;
seconds1 = seconds % 3600;
minutes = seconds1 / 60;
seconds2 = seconds1 % 60;
//Making output box:
JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
} //End of main method.
} //End of class Time2
Bekomme ich die folgende Fehlermeldung, wenn ich versuche zu kompilieren:
Time2.java:28: ')' expected
JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
^
Time2.java:28: not a statement
JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
^
Time2.java:28: ';' expected
JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
^
Time2.java:28: not a statement
JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
^
Time2.java:28: ';' expected
JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
^
Time2.java:28: not a statement
JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
^
Time2.java:28: ';' expected
JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
^
7 errors
Du musst angemeldet sein, um einen Kommentar abzugeben.
Nach jeder
hours
,minutes
undseconds2
müssen Sie einen+
Schild vor den doppelten Anführungszeichen.sollte dies sein:
Die Fehlermeldung ist ein wenig kompliziert. Das eigentliche problem ist hier:
seconds2 "Sekunden."
(es ist eine fehlende " + " - Zeichen zwischen zwei Variablen)