I need help with this Project. I\'ve tried nested while loops and everything but
ID: 3754396 • Letter: I
Question
I need help with this Project. I've tried nested while loops and everything but I cant seem to figure out how to approach it. If someone can give me the correct answer with it matching up to the grading criteria, I'll give instant thumbs up. Thank you so much! ALSO, the code must be written in C language.
| The poal of this prcject is to create a Sing e Row BING0 'card" and to compare the card with randomly generated BINGO calls.BINGO is typ cally played ith a 5xs nd where the tirst column is labeled B, the second the third N', the tourth G, and tnally the ritth U. TheB- column is associated witn integer values 1-15 (ircusive the column with 16-30 (inci.sive), the Nlmn1-45(inclusve the G-calumn BINGO calls are represented by both the etter ard number, e.g. e15, N35, 071 etc. we will not be dealng with a tull bku carc and we will not be play ng a real game ot NGO. Instead your mission 13 to give tre user the croce of two ways to create a s ngle Row BINGhard' consisting of ore entry from each column (ore or each etter in "EINGO2 The first lhd is a uses generated ca, see progr arn asks the user ta eiler in valus x hf hecad re iul. nate: the mumbers surrounded by double asterisks are sample entries from the user and are not actually part of the program output) for method 1 el oma to single Rou BINGO How would you like to c ste your BINGC tard? 2-randonig ganaared PEAARA nter your Generating your card from user input... Enzor a nunbor 16-301 tor I: 2 gnter aunbe: 46-601 for 6 Enter a aunber [1-751 for : 65 Make sure the user entees the values in the BIN GO arder and that the BINGO card is printed ta the screen in precisely he format shown above with a sirgle space between each element of the card The seoand method is a randomly generated card, where the prograrn prowdes the five cand elements using random numbers Here is autput tor method 2 enter your cho-ce: ..2** Randoolv genering your card. Make sure the BINGO card is printed to the screen in precisely the format shown above, with a single space between each element of the cerd. unce a single Row BINGO cad has teen gereated."-lay, a game otSingle Row BING by etting the user decide now many BINGO cals to make Randomy generate BINGO calls. Far each call, check if it is a match to the Sirgle Row BINGO card createc earle in the program, have been made, summarize the game by recorting the total number of BING0s that occurred and the percentage of calls that resulted in a BINGO. Here is a sampe output (agan the dzuble astenska represent user input Your BINGO card i: 37 127 N43 G58 05 Now, let's play Single Row BINGO 63 G58 BI1NE0!! 834 68 071 ane Summary You had 1 BINGO Thanka for playing. Goodbya Grading 35 pointstor style the point breakdown is described ir apiazza post @10. Note. as we havent discussed tunctons yet eerythng shcukd be in man) at this point) 5 points fer ckurly cormric ed input srornts · 10 points for creating a INGO card from user input 10 points tor ransomly generating a BINC0 card 5 points for generating the corect number BINGO cals 5 points for properly regorting the number of cals, number of BINGO!! matches, and percentage of BINGOs · points for randomly generating BINGO calls 10 points for accurately thackirg and raportinBINGOI thes points tor handling erronecus input gracetuly (ie. check it inout is in proper range and a low userto enter anctrer number itno:)Explanation / Answer
//C program
#include<stdio.h>
#include<string.h>
#include<time.h>
//generates random number in given range
int getRandom(int min,int max){
return (rand() % (max - min + 1)) + min;
}
int main() {
printf("Welcome to Single row BINGO ");
printf("How would you like to create your BINGO card");
printf(" 1 - user entered 2 - Randomly generated. ");
printf("Please enter your choice:");
int choice;
int B,I,N,G,O;
scanf("%d",&choice);
if(choice == 1){
printf(" Generating your card from user input...");
while(1){
printf(" Enter a number [01-15] for B:");
scanf("%d",&B);
if(B>=1&&B<=15)break;
else printf("invalid input ");
}
while(1){
printf(" Enter a number [16-30] for I:");
scanf("%d",&I);
if(I>=16&&I<=30)break;
else printf("invalid input ");
}
while(1){
printf(" Enter a number [31-45] for N:");
scanf("%d",&N);
if(N>=31&&N<=45)break;
else printf("invalid input ");
}
while(1){
printf(" Enter a number [46-60] for G:");
scanf("%d",&G);
if(G>=46&&G<=60)break;
else printf("invalid input ");
}
while(1){
printf(" Enter a number [61-75] for O:");
scanf("%d",&O);
if(O>=61&&O<=75)break;
else printf("invalid input ");
}
printf(" Your BINGO card is: B%d I%d N%d G%d O%d",B,I,N,G,O);
} else if(choice==2){
printf(" Randomly generating your card...");
// Use current time as seed for random generator
srand(time(0));
//random
B = getRandom(1,15);
I = getRandom(16,30);
N = getRandom(31,45);
G = getRandom(46,60);
O = getRandom(61,75);
printf(" Your BINGO card is: B%02d I%d N%d G%d O%d",B,I,N,G,O);
}
int call,i=0,r,num;
double count=0;
printf(" How many Bingo call do you want? : ");
scanf("%d",&call);
while(i<call){
r=getRandom(0,4);
if(r==0){
num=getRandom(1,15);
printf("B%02d",num);
if(num==B){count++;
printf(" BINGO!!!! ");}
else printf(" ");
}
else if(r==1){
num=getRandom(16,30);
printf("I%d",num);
if(num==I){count++;
printf(" BINGO!!!! ");}
else printf(" ");
}
else if(r==2){
num=getRandom(31,45);
printf("N%d",num);
if(num==N){count++;
printf(" BINGO!!!! ");}
else printf(" ");
}
else if(r==3){
num=getRandom(46,60);
printf("G%d",num);
if(num==G){count++;
printf(" BINGO!!!! ");}
else printf(" ");
}
else if(r==4){
num=getRandom(46,60);
printf("O%d",num);
if(num==O){count++;
printf(" BINGO!!!! ");}
else printf(" ");
}
i++;
}
printf(" Game Summary : ");
printf("After %d BINGO calls ",call);
printf("You have %d BINGO ",(int)count);
printf("You got a BINGO %f of the time ",(count/call)*100);
return 0;
}