Question
[Basic C Program} Create a player position enum with the following positions: - GOALKEEPER - FORWARD - BACK - MIDFIELDER Add this enum to the
[Basic C Program}
Create a player position enum with the following positions: - GOALKEEPER - FORWARD - BACK - MIDFIELDER
Add this enum to the player data struct...BUT...you do not need to prompt for this data in V2....simply create the "place holder" for the data in the struct!
We are going to replace our multiple arrays with a single array and create a struct to hold all the player information.
typedef struct playerData_struct { Jersey Number (integer, between 1-99) Player Name (char [100] array) Player Rating (double, between 0.0-100.0) Player Position (one of the 4 enum values defined above) } playerData;
You need to add the following 2 functions to validate the user's input AND use them in your implementation:
bool jerseyValid(int playeJerseyNumber); bool ratingValid(double playerRating);
If the input value is not valid, then the function returns false otherwise it should return true.
If the input data is not valid, then break from the input process and redisplay the menu.
You need to add the following function AND use it in your implementation
void printPlayer(playerData* thisPlayer); This function will take a pointer to a player information struct and print all the information for one player, formatted as in version 1: Player Name Player Jersey # Player Rating
You should implement V2 in a similar manner to V1, using a jersey # of 0 to indicate an empty slot in the roster array.
HINT: Start by converting your 3 array implementation to the use of the 1 array w/struct before adding the additional features.
----------------------------------------------------------------------------- VERSION 1 ...UNCHANGED! -----------------------------------------------------------------------------
This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player:
Name: string, 1-100 characters (nickname or first name only) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0
You must use 3 arrays to store this information. You should initialize each array with appropriate values. There will be no more than 10 players on each team.
You will implement a menu of options for the user to build and modify the roster. Each option is represented by a single character. The program initially outputs the menu, prompts the user for a choice and then processes that choice (HINT: this is a good place to use a switch statement.) The menu is provided as part of the start code and looks like this:
MENU a - Add a new player u - Update player information r - Remove a player from the roster d - Display player information p - Print the full roster s - Print "Star" players q - Quit
Please make a selection:
Each option should operate as follows: -------------------------------------------------------------------------------------------
a - Add a new player, prompts the user as follows Enter player jersey number: Enter player first or nick name: Enter player rating: NOTE: lookup the player info by jersey number... if found...display an error message and return to the menu if not found...enter the data as above NOTE: If the maximum number of players has been entered... display an error message and return to the menu NOTE: You do not need to validate the range of the rating.
(HINT: entering the player name can be done with a scanf)
-------------------------------------------------------------------------------------------
u - Update player information Enter player jersey number: NOTE: lookup the player info by jersey number... if found...prompt for name and rating as in option 'a' if not found...display an error message and return to the menu NOTE: You do not need to validate the range of the rating.
-------------------------------------------------------------------------------------------
r - Remove a player from the roster Enter player jersey number: NOTE: lookup the player info by jersey number... if found...remove the player if not found...display an error message and return to the menu
-------------------------------------------------------------------------------------------
d - Display player information Enter player jersey number: Display the following: Name: Jersey #: Rating: NOTE: lookup the player info by jersey number... if found...display the information if not found...display an error message and return to the menu -------------------------------------------------------------------------------------------
p - Print the full roster Prints all the information for all the players: ROSTER ------- Player Name 1 Player Jersey # Player Rating Player Name 2 Player Jersey # Player Rating ... for as many players as have been entered ...
-------------------------------------------------------------------------------------------
s - Print "STAR" players Prints all the players with a rating greater than the star rating Prompt the user as follows: Enter "STAR" rating: MY STARS -------- Player Name 1 Player Jersey # Player Rating Player Name 2 Player Jersey # Player Rating ... for as many players as meet the criteria... and there may be none!
-------------------------------------------------------------------------------------------
q - Quit Normal exit for the program
-------------------------------------------------------------------------------------------
Your program will need to implement the following function: int findPlayer(int whichPlayer, const int jerseyNumbers[], int maxJersyCount);
This function takes a player jersey 3 (whichPlay) and looks for that value in the jerseyNumber array.
If found...return the index number if NOT found...return a -1
You will need this function!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started