Sie sind auf Seite 1von 9

Carlos Vicente E.

Torralba
Lab Exam

CS 201
Sir Jheil Baculod

BINGO
FLASH BOARD
6 package labexam;
12 import java.util.*;
13 public class LabExam {
18
public static void main(String[] args) {
19
20
// TODO code application logic here
21
int B [] = new int [15];
22
int I [] = new int [15];
23
int N [] = new int [15];
24
int G [] = new int [15];
25
int O [] = new int [15];
26
27
int chosennumbers [] = new int [75];
28
int chknum=0;
29
int a=0;
30
int decision;
31
32
33
LabExam check1 = new LabExam();
34
Random Object1 = new Random ();
35
Scanner dec = new Scanner (System.in);
36
37
System.out.println("\t \t \t \t \t B I N G O");
38
System.out.println("\t \t \t \t \t Flash Board" );
39
System.out.println ();
40
System.out.print ("B");
41
System.out.print("\t \t ");
42
43
for (int ctr = 0; ctr<9; ctr++)
44
{
45
System.out.print (B[ctr] + " ");
46
}
47
48
for (int ctr = 9; ctr<15; ctr++)
49
{
50
System.out.print(B[ctr] + (" "));
Page 1 of 9

Carlos Vicente E. Torralba


Lab Exam

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

CS 201
Sir Jheil Baculod

}
System.out.println ();
System.out.print ("I");
System.out.print("\t \t ");
for (int ctr = 0; ctr<I.length; ctr++)
{
System.out.print (I[ctr] + " ");
}
System.out.println ();
System.out.print ("N");
System.out.print("\t \t ");
for (int ctr = 0; ctr<N.length; ctr++)
{
System.out.print (N[ctr] + " ");
}
System.out.println ();
System.out.print ("G");
System.out.print("\t \t ");
for (int ctr = 0; ctr<G.length; ctr++)
{
System.out.print (G[ctr] + " ");
}
System.out.println ();
System.out.print ("O");
System.out.print("\t \t ");
for (int ctr = 0; ctr<O.length; ctr++)
{
System.out.print (O[ctr] + " ");
}
System.out.println ();
System.out.println ("Do you want to play Bingo: ");
System.out.println ("Type 1 for Yes \nType 2 for No");
do{
System.out.print ("Enter a num: ");
decision = dec.nextInt();
}while((decision!=1)&&(decision!=2));
if (decision == 1)
Page 2 of 9

Carlos Vicente E. Torralba


Lab Exam

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

CS 201
Sir Jheil Baculod

for (int ctr=0; ctr<chosennumbers.length; ctr++)


{
do{
System.out.println ();
System.out.println("Type 1 for Yes");
System.out.println("Type any number for Bingo");
System.out.print("Draw a ball: ");
int decision1=dec.nextInt();
int z;
if (decision1 == 1)
{
System.out.print("Generating Number: " );
chknum= 1+Object1.nextInt(75);
z = check1.find(chosennumbers, chknum);
a=z;
System.out.println();
}
else{
System.out.print("B I N G O");
System.exit(0);
}
if (a==1)
{
System.out.println("Generating another number: ");
}
}while(a!=0);
if ((chknum<=75)&&(chknum>=61))
{
System.out.println("\t \t \t \t O "+"- " + chknum);
chosennumbers[ctr]=chknum;
}
else if ((chknum<=60)&&(chknum>=46) )
{
Page 3 of 9

Carlos Vicente E. Torralba


Lab Exam

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170

CS 201
Sir Jheil Baculod

System.out.println("\t \t \t \t G "+"- " + chknum);


chosennumbers[ctr]=chknum;
}
else if ((chknum<=45)&&(chknum>=31) )
{
System.out.println("\t \t \t \t N "+"- " + chknum);
chosennumbers[ctr]=chknum;
}
else if ((chknum<=30)&&(chknum>=16) )
{
System.out.println("\t \t \t \t I "+"- " + chknum);
chosennumbers[ctr]=chknum;
}
else if ((chknum<=15)&&(chknum>=1) )
{
System.out.println("\t \t \t \t B "+"- " + chknum);
chosennumbers[ctr]=chknum;
}
switch (chknum) {
case 1:
B[0]=1;
break;
case 2:
B[1]=2;
break;
case 3:
B[2]=3;
break;
case 4:
B[3]=4;
break;
case 5:
B[4]=5;
break;
case 7:
B[6]=7;

171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188

break;
case 8:
B[7]=8;
break;
case 9:
B[8]=9;
break;
case 10:
B[9]=10;
break;
case 11:
B[10]=11;
break;
case 12:
B[11]=12;
break;
case 13:
B[12]=13;
Page 4 of 9

Carlos Vicente E. Torralba


Lab Exam

189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228

break;
case 14:
B[13]=14;
break;
case 15:
B[14]=15;
break;
case 16:
I[0]=16;
break;
case 17:
I[1]=17;
break;
case 18:
I[2]=18;
case 19:
I[3]=19;
case 20:
I[4]=20;
break;
case 21:
I[5]=21;
break;
case 22:
I[6]=22;
break;
case 23:
I[7]=23;
break;
case 24:
I[8]=24;
break;
case 25:
I[9]=25;
break;
case 26:
I[10]=26;
break;
case 27:
I[11]=27;

CS 201
Sir Jheil Baculod

229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268

break;
case 28:
I[12]=28;
break;
case 29:
I[13]=29;
break;
case 30:
I[14]=30;
break;
case 31:
N[0]=31;
break;
case 32:
N[1]=32;
break;
case 33:
N[2]=33;
break;
case 34:
N[3]=34;
break;
case 35:
N[4]=35;
break;
case 36:
N[5]=36;
break;
case 37:
N[6]=37;
break;
case 38:
N[7]=38;
break;
case 39:
N[8]=39;
break;
case 40:
N[9]=40;
break;
Page 5 of 9

Carlos Vicente E. Torralba


Lab Exam

269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308

case 41:
N[10]=41;
break;
case 42:
N[11]=42;
break;
case 43:
N[12]=43;
break;
case 44:
N[13]=44;
break;
case 45:
N[14]=45;
break;
case 46:
G[0]=46;
break;
case 47:
G[1]=47;
break;
case 48:
G[2]=48;
break;
case 49:
G[3]=49;
break;
case 50:
G[4]=50;
break;
case 51:
G[5]=51;
break;
case 52:
G[6]=52;
break;
case 53:
G[7]=53;
break;
case 54:

CS 201
Sir Jheil Baculod

309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348

G[8]=54;
break;
case 55:
G[9]=55;
break;
case 56:
G[10]=56;
break;
case 57:
G[11]=57;
break;
case 58:
G[12]=58;
break;
case 59:
G[13]=59;
break;
case 60:
G[14]=60;
break;
case 61:
O[0]=61;
break;
case 62:
O[1]=62;
break;
case 63:
O[2]=63;
break;
case 64:
O[3]=64;
break;
case 65:
O[4]=65;
break;
case 66:
O[5]=66;
break;
case 67:
O[6]=67;
Page 6 of 9

Carlos Vicente E. Torralba


Lab Exam

349
350
351
352
353
354
355
356
357
358
359
360
361
362

break;
case 68:
O[7]=68;
break;
case 69:
O[8]=69;
break;
case 70:
O[9]=70;
break;
case 71:
O[10]=71;
break;
case 72:

CS 201
Sir Jheil Baculod

363
364
365
366
367
368
369
370
371
372
373
374
375
376

O[11]=72;
break;
case 73:
O[12]=73;
break;
case 74:
O[13]=74;
break;
case 75:
O[14]=75;
break;
default:
break;

Page 7 of 9

377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

System.out.print ("B");
System.out.print("\t \t ");
for (int ctr4 = 0; ctr4<9; ctr4++)
{
System.out.print (B[ctr4] + " ");
}
for (int ctr4 = 9; ctr4<15; ctr4++)
{
System.out.print (B[ctr4] + " ");
}
System.out.println ();
System.out.print ("I");
System.out.print("\t \t ");
for (int ctr4 = 0; ctr4<I.length; ctr4++)
{
System.out.print (I[ctr4] + " ");
}
System.out.println ();
System.out.print ("N");
System.out.print("\t \t ");
for (int ctr4 = 0; ctr4<N.length; ctr4++)
{
System.out.print (N[ctr4] + " ");
}
System.out.println ();
System.out.print ("G");
System.out.print("\t \t ");
for (int ctr4 = 0; ctr4<G.length; ctr4++)
{
System.out.print (G[ctr4] + " ");
}
System.out.println ();
System.out.print ("O");
System.out.print("\t \t ");
for (int ctr4 = 0; ctr4<O.length; ctr4++)
{
System.out.print (O[ctr4] + " ");
}

418
419
420
421
422
shown");
423
}
424
425
426
427
428
429
430 }

System.out.println ();
}
System.out.println("There are no more numbers to be
else{
System.out.println("BINGO");
System.exit(0);
}

438 public int find(final int[]bingonumbers, final int ball)


439
{
440
441
442
{
443
for(int i = 0; i<bingonumbers.length; i++)
444
{
445
if(bingonumbers[i]==ball)
446
{
447
448
return 1;
449
}
450
451
}
452
return 0;
453
454
}
455
}
456 }
457

Das könnte Ihnen auch gefallen