-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathLOTTO
51 lines (40 loc) · 1.16 KB
/
LOTTO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.lang.Math;
import java.util.Scanner;
public class LOTTO {
private static int[] lottonumbers = new int[6];
private static int[] usernumbers = new int[6];
private static int x;
private static int user;
public static boolean check;
public static int drawNumber(){
x = (int) (Math.random() * 49);
return x;
}
public static int inputNumber(){
check = false;
do {
Scanner read = new Scanner(System.in);
System.out.println("Gib eine Zahl zwischen 0 und 49 ein:");
user = read.nextInt();
if (0 < user && user < 49) {
check = true;
}
}while(!check);
return user;
}
public static void main(String[] args){
for(int i = 0; i<6; i++){
lottonumbers[i] = drawNumber();
}
for(int i = 0; i<6; i++){
usernumbers[i] = inputNumber();
}
for(int i = 0; i<6; i++){
System.out.print(lottonumbers[i] + " ");
}
System.out.println();
for(int i = 0; i<6; i++){
System.out.print(usernumbers[i] + " ");
}
}
}