I need help with this program in C...please help!!!
1. Review use of logical constructs and functions.
2. Use arrays to solve a problem with many pieces of information of the same type.
3. Use both input and output files.
Problem: Fantasy Football
Last year you came in dead last in your fantasy football league. After taking Introduction to C Programming, you've come up with an idea to take your league by storm. You have access to last year's statistics and have decided to use your C programming skills to examine those stats to create an ordered list of players based upon how your fantasy league awards points. You will write a program that reads in an input file containing all the NFL's players with their statistics and then creates an output file listing the players and their "power rankings" in descending order. This output file will aid you in your draft. In addition to this task, you will pick a league All-Star team using your program. Your program will pick five players: the quarterback with the highest power ranking, the two running backs with the two highest power rankings, and the two wide receivers with the two highest power rankings. This team of All-Stars should be outputted to the screen.
Input File Format
The first line of the input file will contain a single integer n (5 ? n ? 1000), denoting the number of players, for which statistics are listed in the file. You are guaranteed enough players in the file to fill an All-Star team as specified above. The following n lines will have all the statistics for all the players with one player's statistics on a single line. Each line will have the following format:
Name Position PassYrds RushYrds RecYrds TDs
Name will be the player's name and contain no white space characters. It is guaranteed to be 29 characters or less.
Position will be a single character, either 'Q', 'R' or 'W', for quarterback, running back or wide receiver, respectively.
PassYrds will be an integer representing the number of passing yards the player had last season.
RushYrds will be an integer representing the number of rushing yards the player had last season.
RecYrds will be an integer representing the number of receiving yards the player had last season.
TDs will be an integer representing the number of touchdowns the player had last season.
How to Compute a Power Ranking
For each player, their power ranking will be the sum of their passing yards divided by 30, their rushing and receiving yards divided by 10, and 6 times the number of touchdowns. In this computation, use integer division. Thus, if a player had 3150 passing yards, 59 rushing yards and 63 receiving yards and twenty touchdowns, his power ranking would be
3150/30 = 105
(59 + 63)/10 = 12
20*6 = 120
Note that power rankings are always non-negative integers.
Output File Format
The output file you produce should have the following format:
The first line should contain a single integer n, representing the number of players in the file. The following n lines should have information about one player each and be in the following format:
Name Position PowerRanking
Each piece of information on a single line should be separated by a single space.
What your program should do
Your program should first prompt the user for the name of both the input file and the output file. Then, your program should process the input file and write out the sorted list (by descending power ranking) to the output file. If there are any ties, you must break these by name as compared by the string function strcmp. Finally, your program should output five lines listing the five players for your All-Star team to the screen. Each line should list the position, the name, and power ranking of the player, respectively, separated by spaces. The players must be listed as follows: quarterback, followed by the two running backs, followed by the two wide receivers. Both the running backs and wide receivers must be listed in descending order of power ranking.
Sample Input File (players.in)
Manning,Peyton Q 4397 36 0 35
Walker,Javon W 0 123 1084 9
Owens,Terrell W 0 0 1180 13
Jackson,Steven R 0 1528 806 16
Parker,Willie R 0 1494 222 16
Harrison,Marvin W 0 0 1366 12
Tomlinson,Ladainian R 0 1815 508 31
Wayne,Reggie W 0 0 1310 9
Johnson,Larry R 0 1789 410 19
Brees,Drew Q 4424 32 0 26
Sample Output File(players.out)
Tomlinson,Ladainian R 418
Manning,Peyton Q 359
Johnson,Larry R 333
Jackson,Steven R 329
Brees,Drew Q 306
Parker,Willie R 267
Harrison,Marvin W 208
Owens,Terrell W 196
Wayne,Reggie W 185
Walker,Javon W 174
Here's an example of how your program should run. User input is in bold and italics.
Please enter the input file with player data.
Please enter the name of the file you want to store the sorted player data.
Your output file has successfully been stored.
Here is your All-Star team:
Q Manning,Peyton 359
R Tomlinson,Ladainian 418
R Johnson,Larry 333
W Harrison,Marvin 208
W Owens,Terrell 196
You must submit the following .c source file with the following name:
Please submit this file over WebCT.
Although you may use other compilers, your program must compile and run using cygwin or gcc. Please use DevC++ to develop your program. Your program should include a header comment with the following information: your name, course number, section number, assignment title, and date. Also, make sure you include ample comments throughout your code describing the major steps in solving the problem.
Your program will be graded upon the following criteria:
1) Your correctness
2) Your programming style and use of white space. (Even if you have a plan and your program works perfectly, if your programming style is poor or your use of white space is poor you could get 10% or 15% deducted from your grade.)
3) Compatibility to DevC++ C compiler. (Make SURE you save your file as a .c file and NOT a .cpp file.)
Link to test file:
|All times are GMT +5.5. The time now is 21:41.|