Dies ist eine statische Kopie unseres alten Forums. Es sind keine Interaktionen möglich.
This is a static copy of our old forum. Interactions are not possible.

Nadja

Trainee

  • "Nadja" is female
  • "Nadja" started this thread

Posts: 74

Date of registration: Apr 11th 2006

1

Wednesday, April 12th 2006, 9:14am

ein versteckter Fehler im Programm!!!!!

Was ist falsch an dem Programm?????

public class sum7
{
public static void main(String args[])
{
int n;
int s;

s=0;
n=1;

While (n<500)
{
s=s+7*n;
n=n+1;
}

System.out.println("Die Summe der Vielfachen von 7 unter 1000=\t" + s);
}
}

-------------------------------------------------------------------------------

Ich bekomme immer diese Fehlermeldung!!!!!


sum7.java:12: ';' expected
<
^

radicarl

Junior Schreiberling

  • "radicarl" is male

Posts: 243

Date of registration: Oct 7th 2003

Location: H-Town

2

Wednesday, April 12th 2006, 9:22am

du solltest while auf jedenfall klein schreiben

smeyer82

Alter Hase

  • "smeyer82" is male

Posts: 372

Date of registration: Oct 14th 2002

Location: Ex-Kanzlerstadt Hannover

3

Wednesday, April 12th 2006, 9:23am

RE: ein versteckter Fehler im Programm!!!!!

Vielleicht versuchst du mal das While klein zu schreiben. Oder ist das ein Fehler beim kopieren ins Forum.

Dann gibts hier extra ein Code-Tag, damit man auch die Einrückung erkennen kann, was das lesen uns analysieren doch ein wenig einfacher macht.

Außerdem kann man auch Fragen stellen und auf Threads aufmerksam machen ohne gleich seinen Wochenvorrat an Satzzeichen zu verballern.

Aber das ist nur meine Meinung...
"Sir! We are surrounded!" - "Excellent! We can attack in any direction!"

Nadja

Trainee

  • "Nadja" is female
  • "Nadja" started this thread

Posts: 74

Date of registration: Apr 11th 2006

4

Wednesday, April 12th 2006, 9:32am

Danke!

ente

Trainee

  • "ente" is male

Posts: 51

Date of registration: Oct 14th 2003

Location: Hannover

Occupation: AnInf.

5

Wednesday, April 12th 2006, 10:17am

RE: ein versteckter Fehler im Programm!!!!!

Quoted

Original von Nadja


sum7.java:12: ';' expected


Die Fehlermeldung auf ';' kommt von daher, das 'While' nicht als Schlüsselwort 'while' für den Schleifenaufruf erkannt wird. Somit ist dein 'While' wohl eine Methode und deren Aufruf wird mit einem ';' abgeschlossen.

gruss
ente

ente

Trainee

  • "ente" is male

Posts: 51

Date of registration: Oct 14th 2003

Location: Hannover

Occupation: AnInf.

6

Wednesday, April 12th 2006, 10:32am

Das dein Code, nicht die Summe des Vielfachen von 7 unter 1000 errechnet, ist Dir bewusst, oder ?

Du wolltest hier nur fair sein und den Anderen auch die Möglichkeit zur "Selbstfindung" geben - DANKE.

Gruss
ente

Nadja

Trainee

  • "Nadja" is female
  • "Nadja" started this thread

Posts: 74

Date of registration: Apr 11th 2006

7

Wednesday, April 12th 2006, 12:02pm

Hallo Ente,
mein Kompliment, hast ganz genau die Aufgabe angeschaut...lacht

ok,
ich würde es so schreiben :
while(n<=142)

...na?.....lacht

ente

Trainee

  • "ente" is male

Posts: 51

Date of registration: Oct 14th 2003

Location: Hannover

Occupation: AnInf.

8

Wednesday, April 12th 2006, 12:10pm

Viel zu zeitaufwändig ! :D

Schreibe doch gleich:
System.out.println("Die Summe der Vielfachen von 7 unter 1000= 71071");

Nun aber gut,
ente

Nadja

Trainee

  • "Nadja" is female
  • "Nadja" started this thread

Posts: 74

Date of registration: Apr 11th 2006

9

Wednesday, April 12th 2006, 12:28pm

Ansichtssache....lacht