CSE103: Structured Programming
[Spring 2023]
                          Project Report
                     Football Team Management
Course Code : CSE103
Course Title : Structured Programming
Section      : 07
Group Number : 07
Submitted by:
        Student ID                Student Name      Contribution Percentage
2023-1-60-085             Purnendu Bhowmik Shuvro          50%
2023-1-60-143             Md. Sirajul Islam Sagor          50%
1. Introduction:
This project displays a football team management project to the user. Here, you
may enter player information and display their goals and assists. Additionally, you
may create, edit, and remove any player from your team.
2. Function descriptions with output:
Structure, Add player, Update player details, Remove player, Display player
details, Display team details, and Exit.
2.1. Struct player{}:
Description:
User-specified variables are created using structure. It is considerably more
adaptable and open to use. In this case, we established a structure variable named
"player" that contained (char) type name [50], (int) type age, (char) type
strong_foot, (int) type jersey_number, (char) type position [50], (char) type
nationality [50], (int) type goals, and (int) type assists. Later, we used this structure
to construct a function that was used throughout the program.
Code:
struct Player {
   char name[50];
   int age;
   char strong_foot;
   int jersey_number;
   char position[50];
   char nationality[50];
   int goals;
   int assists;
};
2.2. Menu:
                                                                                   Page 2
Description:
Users can select their preferred list on the menu chart and add or update players.
We post a choice question to the user on the menu.
Output:
2.3. void add_player(struct Player players[], int *num_players);
Description:
This function allows the user to add a player to the team. The user will enter the
player's name, age, strong foot, jersey number, position, nationality, number of
goals, and number of assists.
Output:
                                                                               Page 3
2.4. void remove_player(struct Player players[], int *num_players);
Description:
This function allows the user to remove a player from the team by entering the
jersey number.
Output:
2.5. void update_player_details(struct Player players[], int
num_players);
Description:
This function allows the user to update the details of a player by entering the jersey
number and selecting the field that needs to be updated ( jersey number, position,
nationality, number of goals, and number of assists).
Output:
                                                                                Page 4
2.6. void display_team_details(struct Player players[], int num_players);
Description:
This function allows the user to display the details of the team, including the
player's name, age, strong foot, jersey number, position, nationality, number of
goals, number of assists, and the list of players with their details.
Output:
2.6. void display_player_details(struct Player players[], int num_players,
int jersey_number);
Description:
This function allows the user to update the details of a player by entering the jersey
number and selecting the field that needs to be updated ( jersey number, position,
nationality, number of goals, and number of assists).
Output:
                                                                                Page 5
3. Exit:
Description:
This function allows the user to exit the program.
Output:
4. Conclusion:
                                                     Page 6
Beginning this project was difficult for us since we were unfamiliar with the right
usage of structure, string, and pointer. So, throughout the vacation, we took our
time to brainstorm ideas and solutions for this project. Through excellent
teamwork, we eventually completed our assignment on schedule. Overall, we had a
lot of fun and learned a lot. We are extremely grateful to you, sir, for giving us the
chance to collaborate.
5. Appendix:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
# define MAX_PLAYERS 30
struct Player {
   char name[50];
   int age;
   char strong_foot;
   int jersey_number;
   char position[50];
   char nationality[50];
   int goals;
   int assists;
};
void add_player(struct Player players[], int *num_players);
void remove_player(struct Player players[], int *num_players);
void update_player_details(struct Player players[], int num_players);
void display_team_details(struct Player players[], int num_players);
void display_player_details(struct Player players[], int num_players,              int
jersey_number);
int main() {
   struct Player players[MAX_PLAYERS];
   int num_players = 0;
   int choice, jersey_number;
  do {
                                                                                Page 7
  printf("\nFootball Team Management System\n");
  printf("\nMenu:\n");
  printf("1. Add player\n");
  printf("2. Remove player\n");
  printf("3. Update player details\n");
  printf("4. Display team details\n");
  printf("5. Display player details\n");
  printf("6. Exit\n");
  printf("Enter your choice: ");
  scanf("%d", &choice);
  switch(choice) {
    case 1:
       add_player(players, &num_players);
       break;
    case 2:
       remove_player(players, &num_players);
       break;
    case 3:
       update_player_details(players, num_players);
       break;
    case 4:
       display_team_details(players, num_players);
       break;
    case 5:
       printf("Enter the player's jersey number: ");
       scanf("%d", &jersey_number);
       display_player_details(players, num_players, jersey_number);
       break;
    case 6:
       printf("Exiting program. GoodBye and Thank You…\n");
       break;
    default:
       printf("Invalid choice. Please try again.\n");
       break;
  }
} while(choice != 6);
return 0;
                                                                      Page 8
}
void add_player(struct Player players[], int *num_players) {
     if (*num_players >= MAX_PLAYERS) {
        printf("Cannot add more players. Maximum limit reached.\n");
        return;
    }
    struct Player player;
    printf("Enter player name: ");
    scanf("%s", player.name);
    printf("Enter player age: ");
    scanf("%d", &player.age);
    printf("Enter player strong foot (L/R): ");
    scanf(" %c", &player.strong_foot);
    printf("Enter player jersey number: ");
    scanf("%d", &player.jersey_number);
    printf("Enter player position: ");
    scanf("%s", player.position);
    printf("Enter player nationality: ");
    scanf("%s", player.nationality);
    printf("Enter player number of goals: ");
    scanf("%d", &player.goals);
    printf("Enter player number of assists: ");
    scanf("%d", &player.assists);
    players[*num_players] = player;
    *num_players += 1;
    printf("Player added successfully.\n");
}
void remove_player(struct Player players[], int *num_players) {
  int jersey_number, i, j;
  printf("Enter jersey number of player to remove: ");
  scanf("%d", &jersey_number);
  for (i = 0; i < *num_players; i++) {
     if (players[i].jersey_number == jersey_number) {
        for (j = i; j < *num_players - 1; j++) {
           players[j] = players[j+1];
        }
                                                                       Page 9
          *num_players -= 1;
          printf("Player removed successfully.\n");
          return;
      }
    }
    printf("Player not found.\n");
}
void update_player_details(struct Player players[], int num_players) {
  int jersey_number, field_choice, i;
  printf("Enter jersey number of player to update: ");
  scanf("%d", &jersey_number);
  for (i = 0; i < num_players; i++) {
     if (players[i].jersey_number == jersey_number) {
        printf("Select field to update:\n");
        printf("1. Jersey number\n");
        printf("2. Position\n");
        printf("3. Nationality\n");
        printf("4. Number of goals\n");
        printf("5. Number of assists\n");
        printf("Enter your choice: ");
        scanf("%d", &field_choice);
        switch (field_choice) {
           case 1:
             printf("Enter new jersey number: ");
             scanf("%d", &players[i].jersey_number);
             break;
           case 2:
             printf("Enter new position: ");
             scanf("%s", players[i].position);
             break;
           case 3:
             printf("Enter new nationality: ");
             scanf("%s", players[i].nationality);
             break;
           case 4:
             printf("Enter new number of goals: ");
             scanf("%d", &players[i].goals);
             break;
           case 5:
                                                                         Page 10
              printf("Enter new number of assists: ");
              scanf("%d", &players[i].assists);
              break;
            default:
              printf("Invalid choice.\n");
              return;
          }
          printf("Player details updated successfully.\n");
          return;
      }
    }
    printf("Player not found.\n");
}
void display_team_details(struct Player players[], int num_players) {
  int i;
  printf("Team details:\n");
  printf("%-20s %-5s %-10s %-10s %-20s %-10s %-10s %-10s\n", "Name",
"Age", "Foot", "Jersey", "Position", "Nationality", "Goals", "Assists");
  for (i = 0; i < num_players; i++) {
     printf("%-20s %-5d %-10c %-10d %-20s %-10s %-10d %-10d\n",
players[i].name, players[i].age, players[i].strong_foot, players[i].jersey_number,
players[i].position, players[i].nationality, players[i].goals, players[i].assists);
  }
}
void display_player_details(struct Player players[], int num_players,           int
jersey_number) {
   int i;
   for (i = 0; i < num_players; i++) {
      if (players[i].jersey_number == jersey_number) {
          printf("Player details:\n");
          printf("Name: %s\n", players[i].name);
          printf("Age: %d\n", players[i].age);
          printf("Strong foot: %c\n", players[i].strong_foot);
          printf("Jersey number: %d\n", players[i].jersey_number);
          printf("Position: %s\n", players[i].position);
          printf("Nationality: %s\n", players[i].nationality);
          printf("Goals: %d\n", players[i].goals);
          printf("Assists: %d\n", players[i].assists);
                                                                            Page 11
          return;
      }
    }
    printf("Player with jersey number %d not found.\n", jersey_number);
}
                                                                          Page 12