In this project you will be given a file players.txt, which contains some top players in the NBA, with their statistics this season. Assume that this file exist in the current directory of your program. You can also assume that each player's first name, last name, and team name are all less than 256 characters long

Among the statistics, there are PPG (points per game), APG (assists per game), RPG (rebounds per game), and SPG (steals per game).

Each player is given an arbitrary ID, which is the first starting number of each line. In the MVP competition, every player can vote for 3 players who he believes are the best. At the end of each line, there are IDs for three players, which represent votes towards the MVP. Here is a sample file:

ID FirstName LastName Team PPG RPG APG SPG Vote1 Vote2 Vote 3 (not part of the input file)
1 LeBron James Heat 25.0 9.0 9.0 3.0 2 3 4
2 Tony Parker Spurs 30.5 3.0 9.0 2.0 1 8 4
3 Kevin Durant Thunder 16.0 12.0 11.0 2.0 2 7 4
4 Carmelo Anthony Knicks 15.0 6.0 1.0 0.0 1 2 3
5 Chris Paul Clippers 4.0 2.0 3.0 1.0 2 9 10
6 James Harden Rockets 46.0 8.0 6.0 1.0 2 3 4
7 Kobe Bryant Lakers 16.0 4.0 7.0 0.0 7 3 4
8 Dwyane Wade Heat 18.5 5.5 3.5 2.5 1 10 3
9 Russel Westbrook Thunder 28.0 10.0 8.0 1.0 7 2 10
10 Paul George Pacers 27.0 8.0 3.0 2.0 1 9 8

You will use your C skills to perform several tasks. First, let us see an example to understand each line in the file.

1 LeBron James Heat 25.0 9.0 9.0 3.0 2 3 4

This line means the player LeBron James with an ID 1 got 25.0 points per game, 9.0 assists per game, 9.0 rebounds per game, and 3.0 steals per game. In the MVP voting, he gives his three votes to players 2, 3 and 4.

You have to accomplish each of the 3 tasks described below.

Part A: Create structures to save players information. (Your data structures must support search that is faster than linear search as your program needs to efficiently support a large number of player stats.) When given the input as a player’s first name, your program should output all the statistics about this player to the screen in exactly the format outlined below:

bash$ ./nba A Dwyane
There are 1 player(s) with the name Dwyane.
The statistics of Dwyane Wade are:
18.5 point(s) per game;
3.5 rebound(s) per game;
7.8 assist(s) per game;
2.5 steal(s) per game;

Note: If there are multiple players with the same first name, you should print out the stats for each player (sorted by ascending order of their last names).

Part B: Depending on a command-line argument (PPG, APG, RPG or SPG), your program should sort all the players and print the player name with their corresponding statistics in the descending order of input. For example, if the user input “PPG”, the program should sort all the players by their points per game and list their ID, name, and PPG from high to low.

For example:

bash$ ./nba B PPG
All players are ranked from high to low by points per game:
6 James Harden Rockets 46.0
2 Tony Parker Spurs 30.5
9 Russel Westbrook Thunder 28.0
8 Dwyane Wade Heat 18.5
10 Paul George Pacers 27.0
1 LeBron James Heat 25.0
7 Kobe Bryant Lakers 16.0
3 Kevin Durant Thunder 16.0
4 Carmelo Anthony Knicks 15.0
5 Chris Paul Clippers 4.0

Part C: The defense value of a player is calculated as follow:

Defense value = RPG *5 + SPG *3

The offense value of a player is calculated as follow:

Offense value = PPG + APG*2 + RPG/2

Use the two formulas to calculate who the best defense player is and who the best offense player is. Print the results to screen. A sample output for this part is:

bash$ ./nba C
The best defense player is Kevin Durant, with the defense value 66.
The best offense player is James Harden, with the offense value 62.

Part D: In the MVP voting, every first vote counts as 3 points, every second vote counts as 2 points, every third vote counts as 1 point. A player cannot give vote to himself; if he does so, disregard such vote(s) to self. If a player votes more than once for another player, use only the most significant vote for your calculation.

Calculate the vote points each player gets and the one with most points is the MVP. Print the MVP name to the screen. Please note, if a player gives votes to himself for a certain vote, this particular vote is void. But the other votes of this player still counts, if it is not to himself.

For example, the 7th line player in the sample input file is:

7 Kobe Bryant Lakers 16.0 4.0 7.0 0.0 7 3 4

Bryant gives his third vote to himself. This vote does not count. However, player 3 still can get a second vote and player 4 still can get a third vote.

Write a program that does one of the above actions depending on the command line input. Name your executable "nba" which takes three arguments and is invoked as follows:

For Part A: bash$ ./nba A player_name
For Part B: bash$ ./nba B [PPG|APG|RPG|SPG]
For Part C: bash$ ./nba [C]
For Part D: bash$ ./nba [D]

Write the routines in separate C file(s) as appropriate and link it to the main program using a Makefile.

Note: The output should contain the correct information, exactly in the format as presented in the sample output.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.