I am making a program for a soccer team and the user will be shown a roster and
ID: 3826853 • Letter: I
Question
I am making a program for a soccer team and the user will be shown a roster and told to type a number of the player they want to see stats of and i fixed all the errors but it is not giving me an output can anyone help please?
#include <stdio.h>
void Choose()
{
//Module with the switch statement
int menuSelection;
printf("Pick a player number");
scanf("%d", &menuSelection);
//select the number for the player stats and file desired
switch(menuSelection)
{
case 0:
fopen("Neymar.docx","r");
break;
case 1:
fopen("Nili.docx","r");
break;
case 2:
fopen("Messi.docx","r");
break;
case 3:
fopen("Alacer.docx","r");
break;
case 4:
fopen("Turan.docx","r");
break;
case 5:
fopen("D.Suarez.docx","r");
break;
case 6:
fopen("Rakitic.docx","r");
break;
case 7:
fopen("Inesta.docx","r");
break;
case 8:
fopen("Gomes.docx","r");
break;
case 9:
fopen("Busquests.docx","r");
break;
case 10:
fopen("Alena.docx","r");
break;
case 11:
fopen("Nascimento.docx","r");
break;
case 12:
fopen("Vidal.docx","r");
break;
case 13:
fopen("Umtiti.docx","r");
break;
case 14:
fopen("Roberto.docx","r");
break;
case 15:
fopen("Pique.docx","r");
break;
case 16:
fopen("Mathieu.docx","r");
break;
case 17:
fopen("Masherano.docx","r");
break;
case 18:
fopen("Digne.docx","r");
break;
case 19:
fopen("Alba.docx","r");
break;
case 20:
fopen("Stegan.docx","r");
break;
case 21:
fopen("Massip.docx","r");
break;
case 22:
fopen("Cilliesan.docx","r");
break;
case 23:
fopen("Marlon.docx","r");
break;
case 24:
fopen("Rafinha.docx","r");
break;
case 25:
fopen("Carbonell.docx","r");
break;
case 26:
fopen("Cardona.docx","r");
break;
case 27:
fopen("Lopez.docx","r");
break;
}
}
int main()
{
// File Declaration??
FILE *inFile;
// Initialize the choice for the while loop to continue running the loop
int option = 0;
while (option = 0)
{
// Conditional statement for input validation
if (option = 0)
{
printf("1: Neymar 2: Santos 3: Messi 4: Alacer 5. Turan 6: D. Suarez 7: Rakitic 8. Iniesta 9. Gomes 10: Busquests 11: Alena 12: Nascimento 13. Vidal 14: Umtiti 15: Barbosa 16: Roberto 17: Pique 18: Mathieu 19: Masherano 20: Digne 21: Alba 22: Stegan 23: Massip 24: Cilliessan ");
//call the choose switch structure
void Choose();
printf("Do you want to pick another player(0 is yes)?");
//continue to run the program
scanf("%d", option);
}
else
{
// end program with a final promt
printf("Have a nice day!");
}
}
return;
}
Explanation / Answer
Ans
#include <stdio.h>
#include<conio.h>
void Choose()
{
FILE *fp;
//Module with the switch statement
int menuSelection;
printf("Pick a player number");
scanf("%d", &menuSelection);
//select the number for the player stats and file desired
switch(menuSelection)
{
case 0:
fp=fopen("Neymar.docx","r");
break;
case 1:
fp=fopen("Nili.docx","r");
break;
case 2:
fp=fopen("Messi.docx","r");
break;
case 3:
fp=fopen("Alacer.docx","r");
break;
case 4:
fp=fopen("Turan.docx","r");
break;
case 5:
fp=fopen("D.Suarez.docx","r");
break;
case 6:
fp=fopen("Rakitic.docx","r");
break;
case 7:
fp=fopen("Inesta.docx","r");
break;
case 8:
fp=fopen("Gomes.docx","r");
break;
case 9:
fp=fopen("Busquests.docx","r");
break;
case 10:
fp=fopen("Alena.docx","r");
break;
case 11:
fp=fopen("Nascimento.docx","r");
break;
case 12:
fp=fopen("Vidal.docx","r");
break;
case 13:
fp=fopen("Umtiti.docx","r");
break;
case 14:
fp=fopen("Roberto.docx","r");
break;
case 15:
fp=fopen("Pique.docx","r");
break;
case 16:
fp=fopen("Mathieu.docx","r");
break;
case 17:
fp=fopen("Masherano.docx","r");
break;
case 18:
fp=fopen("Digne.docx","r");
break;
case 19:
fp=fopen("Alba.docx","r");
break;
case 20:
fp=fopen("Stegan.docx","r");
break;
case 21:
fp=fopen("Massip.docx","r");
break;
case 22:
fp=fopen("Cilliesan.docx","r");
break;
case 23:
fp=fopen("Marlon.docx","r");
break;
case 24:
fp=fopen("Rafinha.docx","r");
break;
case 25:
fp=fopen("Carbonell.docx","r");
break;
case 26:
fp=fopen("Cardona.docx","r");
break;
case 27:
fp=fopen("Lopez.docx","r");
break;
}
while(1)
{
char ch;
ch = fgetc(fp);
if(ch==EOF)
{
break;
}else{
printf("%c",ch);
}
}
}
int main()
{
// File Declaration??
FILE *inFile;
// Initialize the choice for the while loop to continue running the loop
int option = 0;
while (option != -1)
{
// Conditional statement for input validation
printf("1: Neymar 2: Santos 3: Messi 4: Alacer 5. Turan 6: D. Suarez 7: Rakitic 8. Iniesta 9. Gomes 10: Busquests 11: Alena 12: Nascimento 13. Vidal 14: Umtiti 15: Barbosa 16: Roberto 17: Pique 18: Mathieu 19: Masherano 20: Digne 21: Alba 22: Stegan 23: Massip 24: Cilliessan ");
//call the choose switch structure
Choose();
printf("Do you want to pick another player(0 is yes)(-1 to no)?");
//continue to run the program
scanf("%d", &option);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.