Java programmieren Hilfe!?

1 Antwort

also wenn man KI fragt

import java.util.Random;


public class Zufallszahlen {


    public static void main(String[] args) {
        // Erstelle ein Random-Objekt
        Random random = new Random();


        // Erstelle eine Zufallszahl von 0 bis 1 Milliarde
        int zufallszahl = random.nextInt(1000000000);


        // Gib die erste Zufallszahl aus
        System.out.println("Die erste Zufallszahl ist: " + zufallszahl);


        // Erstelle eine Schleife, um 20 weitere Zufallszahlen zu erzeugen
        for (int i = 0; i < 20; i++) {
            // Erstelle eine neue Zufallszahl, die kleiner als die vorherige ist
            zufallszahl = random.nextInt(zufallszahl);


            // Gib die neue Zufallszahl aus
            System.out.println("Die nächste Zufallszahl ist: " + zufallszahl);
        }
    }
}