View Full Version : [Frage] Dringende Hilfe gesucht- Runde 2
Bin Java-Anfänger, und kämpfe ziemlich mit dem Zeug. Momentan habe ich folgendes Problem. Beim Compilieren des modifizierten Progs kommen Fehlermeldungen die ich nicht verstehe, und die vor meinen Änderungen nicht da waren.
Kann mir wer helfen und die Fehler erklären?
import eprog.*;
public class Testen
{
static String eingabe;
static int betrag;
static int unit [];
static int anzahl;
static int i;
String ret="";
public static String perform() throws NumberFormatException;
eingabe = EprogreadWord();
try
{
betrag = java.lang.Integer.parseInt(eingabe.substring(0,ein gabe.length()-1),10);
if (betrag > 10000000 || betrag < 1 )
{
ret += ("FALSCHE EINGABE");
}
else if (eingabe.endsWith("C") == true)
{
if (betrag >= 2)
{
ret += ("S ");
int unit [] = {800, 500, 100, 50, 10, 2, 0};
for (i = 0; unit[i] != 0; i++)
{
anzahl = betrag / unit[i];
if (anzahl != 0)
{
betrag = betrag % unit[i];
ret += (unit[i] + " " + anzahl + " ");
}
}
}
if (betrag == 1 )
{
ret += ("M 1 1 ");
betrag = 0;
}
}
else if (eingabe.endsWith("D") == true)
{
if (betrag >= 4)
{
ret += ("S ");
int unit [] = {400, 100, 50, 20, 4, 0};
for (i = 0; unit[i] != 0; i++)
{
anzahl = betrag / unit[i];
if (anzahl != 0)
{
betrag = betrag % unit[i];
ret += (unit[i] + " " + anzahl + " ");
}
}
}
if (betrag >= 1 )
{
ret += ("M ");
int unit [] = {2, 1, 0};
for (i = 0; unit[i] != 0; i++)
{
anzahl = betrag / unit[i];
if (anzahl != 0)
{
betrag = betrag % unit[i];
ret += (unit[i] + " " + anzahl + " ");
}
}
}
}
else
{
ret += ("FALSCHE EINGABE");
}
}
catch (NumberFormatException e)
{
ret += ("FALSCHE EINGABE");
}
return (ret);
}
}
... sind die Fehler die er mir anzeigt:
C:...:48: <identifier> expected
eingabe = EprogIO.readWord();
^
C:...:50: illegal start of type
try
^
C:...:164: <identifier> expected
return (ret);
^
C:...:166: 'class' or 'interface' expected
}
^
C:... :169: 'class' or 'interface' expected
^
C:...:48: cannot resolve symbol
symbol : class eingabe
location: class Testen
eingabe = EprogIO.readWord();
^
C:...:44: missing method body, or declare abstract
public static String perform() throws NumberFormatException;
^
7 errors
Prozess beendet mit Exit-Code 1
KarlMurx
11-05-2004, 21:28
public static String perform() throws NumberFormatException;
So auf den ersten Blick denk ich mal du willst eher
public static String perform() throws NumberFormatException
{
// ...
}
... jetzt gehts!
FUCK! Den Blick muss ich wohl noch lernen...
KarlMurx
11-05-2004, 22:10
... jetzt gehts!
FUCK! Den Blick muss ich wohl noch lernen...
Der kommt mit der Zeit praktisch ganz von selbst (man muss nur oft genug solange durchprogrammieren bis praktisch alles vor den Aufgen verschwimmt ;) )
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.