-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBingo.java
More file actions
64 lines (39 loc) · 1.16 KB
/
Bingo.java
File metadata and controls
64 lines (39 loc) · 1.16 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.Random;
import java.util.*;
public class Bingo {
public static void main(String[] args) {
int bingo[][]= new int[4][4];
int i, j, soma=0, nCantado, rodadas;
Random aleatorio = new Random();
Scanner ler = new Scanner(System.in);
for(i=0; i<4; i++){
for(j=0; j<4; j++) {
bingo[i][j] = aleatorio.nextInt(75)+1;
soma = soma + bingo[i][j];
}
}
for(i=0; i<4; i++){
System.out.print("[ ");
for(j=0; j<4; j++) {
System.out.print(bingo[i][j] + " ");
}
System.out.print("]\n");
}
for(rodadas=0; soma!= 0 ; rodadas++){
System.out.println("Escreva o número cantado:");
nCantado = ler.nextInt();
for(i=0; i<4; i++){
for(j=0; j<4; j++) {
if (nCantado==bingo[i][j]) {
System.out.println("Parabéns, você tem este número!");
soma = soma - bingo[i][j];
bingo[i][j] = 0;
}else {
System.out.println("Que pena, você não tem este número!");
}
}
}
}
System.out.println("BINGO! Você demorou " + rodadas + " rodadas para vencer");
}
}