Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Lotto {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out
- .println("Wieviele Felder des Lottoscheins wollen sie ausfüllen? ");
- int amount = sc.nextInt();
- // Speicherarray 2. Dimensional. 1 Dimension für die Felder, 2. für die
- // Zahlen
- int[][] speicher = new int[amount][6];
- // Prüfung ob eine passende Anzahl an Feldern eingegeben wurde
- if (amount > 12 || amount < 1) {
- System.out.println("Eingabe inkorrekt.");
- }
- // Befüllung des speicher Arrays
- for (int i = 0; i < amount; i++) {
- for (int j = 0; j < 6; j++) {
- int x = (int) (Math.random() * 49) + 1;
- speicher[i][j] = x;
- }
- }
- // Ausgeben des Arrays
- for (int i = 0; i < speicher.length; i++) {
- System.out.println("Feld " + (i + 1) + ": ");
- for (int j = 0; j < 6; j++) {
- System.out.print(speicher[i][j] + " ");
- System.out.println();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment