Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

BINGO This is a fully functioning program. Make sure that it compiles and run an

ID: 3774273 • Letter: B

Question

BINGO This is a fully functioning program. Make sure that it compiles and run and test it for a while. This program uses C structs to store data. REWRITE this program so that it does not use structs. Instead, use a 2D array of 2D arrays, (A 4D array actually) with the following value encoding shown below. I suggest you develop the program by getting it to work with one bingo board first. You will have to change the way you are passing the boards around, see the prototypes below. There are several nested loops, the indexing ranges will change slightly, but the nesting order should not change. Mostly, you will be changing the way you reference data elements, and a little bit of logic. // use this global table of Bingo boards instead of structs // Trow Tcol Brow Bcol unsigned char Table[TROWS][TCOLS][6] [5]; /* Value Encoding: 1-50 numbers Page 7 of 7 250 the ASCII dot, indicates that this number has been picked (not visible) 66 B 73 I 78 N 71 G 79 O */ // new prototypes for passing board array data void initBoard(char B[6][5]); void printBoard(char B[6][5]); Hints: There is a line in play() with: Table[Trow][Tcol].nums[Brow][Bcol] that will change to: Table[Trow][Tcol][Brow][Bcol] And another line in play() with: Table[Trow][Tcol].visflag[i][Bcol] != 0 that will change to: Table[Trow][Tcol][i][Bcol] != 250 And a few other similar changes elsewhere.

4) BINGO Download "bingo struct.c" from the instructor's website. This is a fully functioning program. Make sure that it compiles and run and test it for a while. This program uses C structs to store data. REWRITE this program so that it does not use structs Instead, use a 2D array of 2D arrays, (A 4D array actually) with the following value encoding shown below I suggest you develop the program by getting it to work with one bingo board first. You will have to change the way you are passing the boards around, see the prototypes below. There are several nested loops, the indexing ranges will change slightly, but the nesting order should not change. Mostly, you will be changing the way you reference data elements and a little bit of logic use this global table of Bingo boards instead of structs Trow Tcol Brow Bcol unsigned char Table ITROWS][TCOLS] [6] [5]; Value Encoding: 1-50 numbers Page 6 of 7 250 the ASCII dot, indicates that this number has been picked (not visible) 66 B 73 I 78 N 71 79 new prototypes for passing board array data void initBoard (char B[6][5]); void print Board(char B[6][5]); Hints: There is a line in play() with Table TrowITcoll nums[Brow] Bcol that will change to Table Trow][Tcol][Brow][Bcoll And another line in play() with: TableTrowITcoll.visflaglil[Bcoll 0 that will change to Table Trowir Tcollril[Bcoll 250 And a few other similar changes elsewhere

Explanation / Answer

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

void main(void)

{

    int Bingo_Card[5][10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,

                 10, 11, 12, 13, 14, 15, 16, 17, 18,

                 81, 82, 83, 84, 85, 86, 87, 88, 0 };

    int Bingo_Numbers[90];

    int Random;

    int x = 0;

    int y;

                int a,b,c;

    int Match_Count = 0;

    srand((unsigned)time(NULL));

    for (c = 0; Match_Count < 15; x++){      /*Matching Numbers Loop*/

    printf (" Press any key to draw another number");

    getche();

    Random = rand() % 90 + 1;

        for (y = 0; y < 90; ){

                    

        if (Random == Bingo_Numbers[y])

            {

             Random = rand() % 90 + 1;

             y = 0;

                    }

        else y++;              

                }

                Bingo_Numbers[x] = Random;

        printf (" Drawn Number %2d: %2d ", x + 1, Bingo_Numbers[x]);

        for (a = 0; a < 10; a++){     /* a is y dimension of array being checked */

            for (b = 0; b < 5; b++){ /* b is x dimension of array being checked */

        

                if (Bingo_Numbers[x] == Bingo_Card[a][b]){

                    Match_Count++;

                    printf ("Match on number %2d ", Bingo_Numbers[x]);

                    printf ("You now have %2d numbers left to match! ", 15 - Match_Count);

                    printf ("Bingo Card Location x: %d y: %d ", b,a);

                    }

            }

        }

                        

    }

    printf ("BINGO!");

    

}

The standard Bingo card is a 5 by 5 table containing integers between 1 and 75, with a free spot at the center that contains 0.

The first column in the table contains only integers between 1 and 15, the second column numbers are all between 16 and 30, the third are 31 to 45, the fourth 46­60, and the fifth 61­75. There are no duplicate numbers on a Bingo card. There are about 155 × 145 × 135 × 125 × 11 4 possible arrangements of the numbers on a bingo card. Before the game starts, each player is given a Bingo card. The game also has a "caller", who issues a list of all the integers between 1 and 75 in random order. As each number is called, players mark the appropriate squares on their cards. The middle square, the free square, is always marked. The winner of the game is the first person whose Bingo card has one of the following winning conditions:

Implement a method public void write(String outputFile) that writes a random Bingo card configuration and a stream of random numbers (which you will generate by the shuffle() method below) between 1 and 75 to the output file. The first five lines of the output represent the Bingo card. Each line is a row of five integers separated by spaces. The third number in the third line, the free square, is always contain the number 0. Next will come seventy five integers, all in one line, in random order. For example, 3 18 34 60 75

12 26 38 47 73

2 23  0 49 66

15 21 43 58 67

6 22 31 56 62

59 69 7 39 32

44 27 53 21 25 28 9 17 61 12 37 5 55 [et cetera, until all numbers have been listed] The first column in the Bingo card configuration must contain only integers between 1 and 15 the second column numbers are all between 16 and 30, the third are 31 to 45, the fourth 46­60, and the fifth 61­75. There are no duplicate numbers on a Bingo card. You are also to implement public void shuffle(ArrayList list) that shuffles a given list of numbers. You shall use this method to generate a list of random integers within the write() method. Note, you cannot call the Collections.shuffle() method.