Soccer team roster (C programming) This program will store roster and rating inf
ID: 3839413 • Letter: S
Question
Soccer team roster (C programming)
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>
void main(){
int jearsy[5];
int rating[5];
char choice;
int jearsy_num, int rating_val;
int jearsy_num1;
int found;
for (int i = 0; i<5; i++){
printf("%s %d %s ", "Enter player ", i+1, "'s jearsy number")
scanf("%d",&jearsy[i]);
printf("%s %d %s ", "Enter player ", i+1, "'s rating")
scanf("%d",&rating[i]);
}
printf("ROSTER ");
for (int i = 0; i<5; i++){
printf("%s %d %s %d %s %d ", "Player ", i+1, "--jearsy number:", jearsy[i], ", Rating:", rating[i]);
}
do {
printf("u - Update player rating ");
printf("a - Output players above a rating ");
printf("r - Replace player ");
printf("o - Output roster ");
printf("q - Quit ");
scanf("%d",&choice)
switch (choice) {
case 'u':
printf("Enter a jersey number ");
scanf("%d", &jearsy_num);
printf("Enter a new rating for player ");
scanf("%d", &rating_val);
found = 0;
for (int i=0; i<5; i++){
if (jearsy[i] == jearsy_num){
found = 1;
rating[i] = rating_val;
}
}
if (found == 0)
printf("Record not found ");
case 'a':
printf("Enter a rating ");
scanf("%d", &rating_val);
for (int i=0; i<5; i++){
if (rating[i] > rating_val){
printf("%s %d %s %d %s %d ", "Player ", i+1, "--jearsy number:", jearsy[i], ", Rating:", rating[i]);
}
}
case 'r':
printf("Enter a jersey number ");
scanf("%d", &jearsy_num);
printf("Enter a new ersey number ");
scanf("%d", &jearsy_num1);
printf("Enter a rating for the new player ");
scanf("%d", &rating_val);
found = 0;
for (int i=0; i<5; i++){
if (jearsy[i] == jearsy_num){
found = 1;
jearsy[i] = jearsy_num1;
rating[i] = rating_val;
}
}
if (found == 0)
printf("Record not found ");
case 'o':
printf("ROSTER ");
for (int i=0; i<5; i++){
printf("%s %d %s %d %s %d ", "Player ", i+1, "--jearsy number:", jearsy[i], ", Rating:", rating[i]);
}
}
} while (choice != 'q')
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.