G
Guest
Gast
Hallo,
kann mir jemand helfen und sagen wo der Fehler ist?
Fehlermeldung lautet:
"illegal start of expression - public int neumann()"
gruß und vielen lieben dank
kann mir jemand helfen und sagen wo der Fehler ist?
Code:
import java.io.*;
public class zufallszahlen
{
public static void main (String argv[]) throws IOException
{
Zufallszahlen zz = new zufallszahlen();
int zahl = zz.neumann();
String str;
int gen_wahl = 1;
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println();
System.out.println("\t::Zufallszahlen::");
System.out.println("\tVon Neumann-Generator:\t 1");
System.out.println("\tQuadrattest-Generator:\t 2");
System.out.println("\tLineare Kongruenz-Generator:\t 3");
System.out.print("\tWaehlen Sie den zu verwendenen Generator");
str = input.readLine();
gen_wahl = Integer.parseInt(str);
switch(gen_wahl)
{
case 1: neumann(); break;
case 2: quadratrest(); break;
case 3: kongruenz(); break;
default: System.out.println("\tFehler");
}
public int neumann()
{
int startwert = 50;
int k = 10;
System.out.println("\t<<Von Neumann-Generator>>");
System.out.println("\tGeben Sie einen ganzzahligen ");
System.out.print("\tStartwert von 2 bis 999999 ein ");
str = input.readLine();
startwert = Integer.parseInt(str);
System.out.println("\tBestimmen Sie nun die Anzahl ");
System.out.print("\tder Wiederholungen: ");
str = input.readLine();
k = Integer.parseInt(str);
int z = startwert;
for (int i=0; i<k; i++)
{
if (z < 1000)
{
z = z*z;
}
else
{
z = (z*z)%1000000000;
z = z/1000;
}
}
System.out.println("Ihre zufaellig erstellte *Pseudo*-Zufallszahl: " + z);
return 0;
}
public int quadratrest()
{
// ...
return 0;
}
public int kongruenz()
{
System.out.println("\t<<Lineare Kongruenz-Generator>>");
int a,b,c,k,z;
System.out.print("\tGeben Sie eine Zahl a ein: ");
str = input.readLine();
a = Integer.parseInt(str);
System.out.print("\tGeben Sie nun eine Zahl b ein, die teilerfremd sein soll: ");
str = input.readLine();
b = Integer.parseInt(str);
System.out.println("\tGeben Sie nun eine Zahl n ein, die teilerfremd und ");
System.out.print("\tgleichzeitig ein Teiler der Zahl a-1 sein soll");
str = input.readLine();
n = Integer.parseInt(str);
System.out.println("\tBestimmen Sie nun die Anzahl k ");
System.out.print("\tder Wiederholungen: ");
str = input.readLine();
k = Integer.parseInt(str);
System.out.print("Geben Sie nun noch einen Startwert z ein! ");
str = input.readLine();
z = Integer.parseInt(str);
for (int i=0; i<k; i++)
{
z = z*a;
z = z+b;
z = z%n;
}
System.out.println("Ihre zufaellig erstellte *Pseudo*-Zufallszahl: " + z);
return 0;
};
}
}
Fehlermeldung lautet:
"illegal start of expression - public int neumann()"
gruß und vielen lieben dank