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

(ARRAYS) Soccer team roster (C) (#include <stdio.h>) This program will store ros

ID: 3729695 • Letter: #

Question

(ARRAYS) Soccer team roster (C) (#include <stdio.h>)

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>

#include<conio.h>

int main()

{

const int SIZE = 5;

int jerseyNumbers[SIZE], ratings[SIZE];

for (int i = 0; i < SIZE; i++)

{

x:

printf("Enter player %d's jersey number: ", (i + 1));

scanf("%d", &jerseyNumbers[i]);

if (jerseyNumbers[i] < 0 || jerseyNumbers[i]>99)

goto x;

y:

printf("Enter player %d's rating: ", (i + 1));

scanf("%d", &ratings[i]);

if (ratings[i] < 1 || ratings[i]>9)

goto y;

}

//output Roster

printf("ROSTER ");

for (int i = 0; i < SIZE; i++)

{

printf("Player %d -- Jersey number: %d, Rating: %d ", (i + 1), jerseyNumbers[i], ratings[i]);

}

//menu

char choice2 ;

char choice;

do {

printf("MENU ");

printf("u - Update player rating a-Output players above a rating r-Replace player o - Output roster q- Quit Choose an option: ");

scanf(" %c", &choice);

switch (choice)

{

case 'u':

case 'U':

printf("Enter a jersey number: ");

int number;

scanf("%d", &number);

for (int i = 0; i < SIZE; i++)

{

if (number == jerseyNumbers[i])

{

printf("Enter a new rating for player: ");

scanf("%d", &ratings[i]);

break;

}

}

break;

case 'a':

case 'A':

printf("Enter a rating: ");

int rating;

scanf("%d", &rating);

printf("ABOVE %d ", rating);

for (int i = 0; i < SIZE; i++)

{

if ( ratings[i]>rating)

{

printf("Player %d -- Jersey number: %d, Rating: %d ", (i + 1), jerseyNumbers[i], ratings[i]);

}

}

break;

case 'r':

case 'R':

printf("enter a jersey number: ");

int jerseyNumber;

scanf("%d", &jerseyNumber);

for (int i = 0; i < SIZE; i++)

{

if (jerseyNumbers[i] == jerseyNumber)

{

j:

printf("Enter a new jersey number: ");

scanf("%d", &jerseyNumbers[i]);

if (jerseyNumbers[i] < 0 || jerseyNumbers[i]>99)

goto j;

r:

printf("Enter a rating for the new player: ");

scanf("%d", &ratings[i]);

if (ratings[i] < 1 || ratings[i]>9)

goto r;

break;

}

}

break;

case 'o':

case 'O':

printf("ROSTER ");

for (int i = 0; i < SIZE; i++)

{

printf("Player %d -- Jersey number: %d, Rating: %d ", (i + 1), jerseyNumbers[i], ratings[i]);

}

break;

case 'q':

case 'Q':

break;

default:

printf("Worng choice: ");

break;

}

printf(" Do you want to continue:(y/n) ");

scanf(" %c", &choice2);

} while (choice2 == 'y' || choice2 == 'Y');

getch();

}

//If you need any help regarding this solution please leave a comment thanks