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

Soccer team roster (C) (#include <stdio.h> ONLY)(maybe string or math.h library

ID: 3730516 • Letter: S

Question

Soccer team roster (C) (#include <stdio.h> ONLY)(maybe string or math.h library if needed)

This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team.

(1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int array and the ratings in another int array. Output these arrays (i.e., output the roster). (3 pts)

Ex:

(2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to Quit. For this step, the other options do nothing. (2 pt)

Ex:

(3) Implement the "Output roster" menu option. (1 pt)

Ex:

(4) Implement the "Update player rating" menu option. Prompt the user for a player's jersey number. Prompt again for a new rating for the player, and then change that player's rating. (1 pt)

Ex:

(5) Implement the "Output players above a rating" menu option. Prompt the user for a rating. Print the jersey number and rating for all players with ratings above the entered value. (2 pts)

Ex:

(6) Implement the "Replace player" menu option. Prompt the user for the jersey number of the player to replace. If the player is in the roster, then prompt again for a new jersey number and rating. Update the replaced player's jersey number and rating. (2 pts)

Ex:

Explanation / Answer

#include<stdio.h>

main()
{
// DECLARING variables
int count,i,j,g[100],r[100],rem,mod,abov;
char choice;
  
// taking user input for first 5 playres
for(count=0;count<5;count++)
{
printf(" Enter player %d's jersey number: ",count+1);
scanf("%d",&g[count]);
  
printf("Enter player%d's rating: ",count+1);
scanf("%d",&r[count]);
}
  
while(1)
{
// taking user input of choice
printf(" MENU a - Add player d - Remove player u - Update player rating r - Output players above a rating o - Output roster q - Quit Choose an option: ");
scanf(" %c",&choice);
// for Quit
if(choice == 'q')
{
break;
}
  
// r - Output players above a rating
else if(choice == 'r')
{
printf("Enter a rating: ");
scanf("%d",&abov);
for(i=0,j=0;i<count;i++)
{
if(r[i] > abov)
{
printf("Player %d -- Jersey number: %d, Rating: %d ",j+1, g[i], r[i]);
j++;
}
}
}
  
// u - Update player rating
else if(choice == 'u')
{
printf("Enter a jersey number: ");
scanf("%d",&mod);
for(i=0;g[i]!=mod;i++);
printf("Enter a new rating for player: ");
scanf("%d",&r[i]);
}
  
// d - Delete player
else if(choice == 'd')
{
printf("Enter a jersey number: ");
scanf("%d",&rem);
for(i=0;g[i]!=rem;i++);
g[i] = 0;
r[i] = 0;
}
  
//a - Add player
else if(choice == 'a')
{
printf("Enter player%d's jersey number: ",count+1);
scanf("%d",&g[count]);
printf("Enter player%d's rating: ",count+1);
scanf("%d",&r[count]);
count++;
}
  
// o - Output roster
else if(choice == 'o')
{
for(i=0,j=0;i<count;i++)
{
if(g[i]!=0)
{
printf("Player %d -- Jersey number: %d, Rating: %d ",j+1,g[i],r[i]);
j++;
}
}
}
  
}

}

/* SAMPLE Output
Enter player1's jersey number: 10
Enter player1's rating: 9

Enter player2's jersey number: 9
Enter player2's rating: 8

Enter player3's jersey number: 8
Enter player3's rating: 7

Enter player4's jersey number: 7
Enter player4's rating: 6

Enter player5's jersey number: 6
Enter player5's rating: 5

MENU
a - Add player
d - Remove player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit

Choose an option: a
Enter player6's jersey number: 5
Enter player6's rating: 4

MENU
a - Add player
d - Remove player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit

Choose an option: d
Enter a jersey number: 8

MENU
a - Add player
d - Remove player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit

Choose an option: o
Player 1 -- Jersey number: 10, Rating: 9
Player 2 -- Jersey number: 9, Rating: 8
Player 3 -- Jersey number: 7, Rating: 6
Player 4 -- Jersey number: 6, Rating: 5
Player 5 -- Jersey number: 5, Rating: 4

MENU
a - Add player
d - Remove player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit

Choose an option: u
Enter a jersey number: 6
Enter a new rating for player: 2

MENU
a - Add player
d - Remove player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit

Choose an option: o
Player 1 -- Jersey number: 10, Rating: 9
Player 2 -- Jersey number: 9, Rating: 8
Player 3 -- Jersey number: 7, Rating: 6
Player 4 -- Jersey number: 6, Rating: 2
Player 5 -- Jersey number: 5, Rating: 4

MENU
a - Add player
d - Remove player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit

Choose an option: r
Enter a rating: 4
Player 1 -- Jersey number: 10, Rating: 9
Player 2 -- Jersey number: 9, Rating: 8
Player 3 -- Jersey number: 7, Rating: 6

MENU
a - Add player
d - Remove player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit

Choose an option: q
*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote