Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program team.c that maintains information for a soccer team. The program will allow you to add and delete players from your team,

Write a C program team.c that maintains information for a soccer team. The program will allow you to add and delete players from your team, to search your team for players by name or by value they are worth, and to print out part or all of the team. The data in your team will be stored in memory with the use of a linked list, with list nodes representing players. Each node will contain members for storing a players family name (char *) and first name (char *), their position (char) and their value (int). There are four possible positions, each of which is identified by the first character in the words (G)oalkeeper, (D)efender, (M)idfielder and (S)triker. Your linked list must be kept in a special order, with all the goalkeepers first, then the defenders, then the midfielders, and finally the strikers. If there is more than one player in the same position, then the players should be kept in order of their insertion (e.g., the last defender in the team, should be the defender most recently inserted into the list; the first striker in the team should be the striker that was inserted first into the list, and so on). You may assume that no two players that assume the same position in your team have the same family name. Your program should be menu driven, with the user being offered a choice of the six commands described below: ? Insert a new player into the team. The program should prompt the user for a new family name and first name, a position and a value. This information should be placed in a new node that has been created using the malloc function. And then the node should be inserted at the appropriate position in the linked list that stores the team data. Dont forget that the team must be stored in a special order, by considering the players position first, and then (if needed) the order of insertion. If a node with the given family name is already in the team, an error message should be produced and the new node should not be inserted into the linked list. ? Delete a player from the team. The program should prompt the user for the family name of the player to be deleted and then delete the node containing that family name from the linked list that stores the team. If no player with the given family name is found in the team, an error message should be produced. ? Search for a player using an input family name. The program should print the family name, first name, position and value of the player, with each piece of information on a separate line. If no player with the given family name is found in the team, an error message should be produced. ? Search for players in the team that are worth less than or equal to an input value. The program should print the family name, first name, position and value of any player that is worth less than or equal to an input value, with each piece of player information on a separate line. A blank line should be printed between each player (if more than one is found). If no player in the team is worth less than or equal to the given value, an error message should be produced. ? Print the team, following a special order. Print the family name, first name, position and value of each player, with each piece of information on a separate line. A blank line should be printed between each player. The special order assumes that the goalkeepers appear first, then the defenders, then the midfielders, and finally the strikers. If there are more than one players of the same position, then they should be printed in order of their insertion. ? Quit the program. When the program is given the quit command, it should delete all nodes in the linked list by using calls to the free function. It should then try to print the linked list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions