Files
java-schule/Aufgaben/PTP_1/Lottozahlen.java

60 lines
2.4 KiB
Java

import java.util.Arrays;
import java.util.Scanner;
public class Lottozahlen {
public static void main(String args[]){
int lottozahlen[] = {17, 9, 39, 23, 41, 6};
//Scanner eingabe = new Scanner(System.in);
/*
int lottozahlen[] = new int[6];
lottozahlen[0] = eingabe.nextInt();
lottozahlen[1] = eingabe.nextInt();
lottozahlen[2] = eingabe.nextInt();
lottozahlen[3] = eingabe.nextInt();
lottozahlen[4] = eingabe.nextInt();
lottozahlen[5] = eingabe.nextInt();
*/
System.out.println("Die heutigen Lottozahlen sind " + lottozahlen);
System.out.println("Es sind " + lottozahlen.length + " Lottozahlen gezogen worden.");
System.out.println("Die erste Lottozahl lautet: " + lottozahlen[0]);
System.out.println("Die zweite Lottozahl lautet: " + lottozahlen[1]);
System.out.println("Die dritte Lottozahl lautet: " + lottozahlen[2]);
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
System.out.println("Die fünfte Lottozahl lautet: " + lottozahlen[4]);
System.out.println("Die sechste Lottozahl lautet: " + lottozahlen[5]);
System.out.println("- - - - - - - - - - - - - - - - - - -");
//lottozahlen[3] = 32;
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
System.out.println("- - - - - - - - - - - - - - - - - - -");
for (int i = 0; i < lottozahlen.length; i++) {
System.out.println("Lottozahl Nr. " + (i + 1) + " lautet " + lottozahlen[i]);
}
System.out.println("- - - - - - - - - - - - - - - - - - -");
for (int zahl: lottozahlen) {
System.out.println("Die aktuelle Lottozahl lautet: " + zahl);
}
System.out.println("- - - - - - - - - - - - - - - - - - -");
Arrays.sort(lottozahlen);
System.out.println("Die erste Lottozahl lautet: " + lottozahlen[0]);
System.out.println("Die zweite Lottozahl lautet: " + lottozahlen[1]);
System.out.println("Die dritte Lottozahl lautet: " + lottozahlen[2]);
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
System.out.println("Die fünfte Lottozahl lautet: " + lottozahlen[4]);
System.out.println("Die sechste Lottozahl lautet: " + lottozahlen[5]);
System.out.println("- - - - - - - - - - - - - - - - - - -");
System.out.println("Die heutigen Lottozahlen sind: " + Arrays.toString(lottozahlen));
}
}