Hallo, Ich habe folgenden Code...
Wie kann ich im main aufruf Pi in der Console ausgeben??
Grüße
Ghostman
Java:
public class pi
{
public static void main(String[] args) {
}
public static double annäherung_pi (int tropfenzahl) {
double pi = 0;
int innerhalb = 0;
int gesamt = tropfenzahl;
while (gesamt > 0) {
double dotx = Math.random();
double doty = Math.random();
if (dotx * doty + doty * doty <= 1) {
innerhalb++;
} else {
}
gesamt--;
}
pi = 4 * (double)innerhalb/tropfenzahl;
return pi;
}
}
Wie kann ich im main aufruf Pi in der Console ausgeben??
Grüße
Ghostman
Zuletzt bearbeitet von einem Moderator: