Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I currently have a code that needs an option 4 that plays a bingo game and declares a winner. this is my current code -------------------------------------------------------------------------

I currently have a code that needs an option 4 that plays a bingo game and declares a winner.

this is my current code

-------------------------------------------------------------------------

#include

#include

int getRandomNumber(int max, int min)

{

return min + (rand() % (max - min + 1));

}

int maxCol(int Col)

{

return ((Col + 1) * 15);

}

int minCol(int Col)

{

return ((Col * 15) + 1);

}

void bingoCard(int cards[5][10][5][5], int Players, int Cards)

{

int i;

int j;

printf(" B I N G O ");

for(i = 0; i

{

for(j = 0; j

{

if(j == 2 && i == 2)

{

printf(" free ");

}

else

{

printf(" %2d ", cards[Players][Cards][i][j]);

}

}

printf(" ");

}

printf(" ");

}

int main()

{

srand(time(NULL));

int numofPlayers;

int numofCards;

int number;

int i;

int j;

int k;

int l;

int m;

int numofRows = 5;

int numCols = 5;

int bingoCards[5][10][5][5];

int count[75];

int Var = 0;

int Generator;

int pick = 1;

printf("Enter number of players: ");

scanf("%d", &numofPlayers);

if(numofPlayers > 5)

{

printf("Max players allowed are 5, please enter a number less than 5 ");

printf("Enter number of players: ");

scanf("%d", &numofPlayers);

}

printf("Enter the number of BINGO cards per player: ");

scanf("%d", &numofCards);

if(numofCards > 10)

{

printf("Max number of cards are 10, please enter a number less than 10 ");

printf("Enter the number of BINGO cards per player: ");

scanf("%d", &numofCards);

}

printf("You are playing a game with %d players and each player will have %d cards ", numofPlayers, numofCards);

printf("We have generated %d bingo cards. ", (numofPlayers * numofCards));

for(i = 0; i

{

for(j = 0; j

{

for(k = 0; k

{

for(l = 0; l

{

while(pick)

{

number = getRandomNumber(minCol(k), maxCol(k));

Var = 0;

for(m = 0; m

{

if(bingoCards[i][j][m][k] == number)

{

Var = 1;

}

}

if(Var == 0)

{

break;

}

}

bingoCards[i][j][l][k] = number;

}

}

}

}

for(i = 0; i

{

count[i] = 0;

}

for(i = 0; i

{

for(j = 0; j

{

for(k = 0; k

{

for(l = 0; l

{

if(!(k == 2 && l == 2))

{

count[bingoCards[i][j][k][l] - 1]++;

}

}

}

}

}

while(pick)

{

printf("Please choose an option from the following menu: ");

printf("1) Display a bingo card ");

printf("2) Run a histogram across all bingo cards generated "); //Display menu options for the user

printf("3) Exit ");

printf("You have chosen ");

scanf("%d", &i);

switch(i)

{

case 1:

printf("Enter the player and players card you would like to display, ");

printf("First player is 1, last player is %d ", numofPlayers);

printf("First card is 1, last card is %d ", numofCards);

scanf("%d %d", &j, &k);

bingoCard(bingoCards, (j - 1), (k - 1));

break;

case 2:

for(j = 0; j

{

Generator = (rand() % 25) + 1; // Generates a number from 1 to 25

if(j

{

printf("%d", j + 1);

}

else

{

printf("%d", j + 1);

}

if(j

{

printf("-%d ", Generator);

}

else if(j = 10)

{

printf("-%d ", Generator);

}

else

{

printf("-%d ", Generator);

}

if(j % 10 == 9)

{

printf(" ");

}

}

printf(" ");

break;

case 3:

printf("GoodBye");

return 0;

default:

printf("Invalid choice, try again. ");

break;

}

}

return 0;

}

-------------------------------------------------------------------------------------------------------------------

What my project is asking for

image text in transcribed

image text in transcribed

Create a program that will .do everything from program 2 (create bingo cards), if you didn't get this working just right go see TAs/professor As Soon As Possible .Add an option 4 to your menu for Play Bingo . read in a bingo call (e,g, B6, 117, G57, G65) . checks to see if the bingo call read in is valid (ie., G65 is not valid) marks all the boards that have the bingo call checks to see if there is a winner, for our purposes winning means 5 tokens in a row or column .5 tokens in a diagonal .1 token in each of the 4 corners of the game board .Loop accepting bingo calls until there is a winner, and display an appropriate message specifying which user won, print their bingo card, and how they won (5 in a row with calls B6, 120 ....5 in a column with calls.. 5 on a diagonal with calls 4 comers with calls....) Grading 35 points style per10 (We will be looking for functions now. So having a function to check for a winner, or initialize the board or,....) 20 points checking for winner code, we expect to see multiple functions here, 1 function that checks for each way of winning (row, col, diag, 4 corners) 10 points checks for valid bingo calls 10 points appropriate message for winner displayed 10 points game play works until winner is found 5 points recording which calls were received, 10 points marking the boards with the calls that have been received

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions