1. Engineering
2. Computer Science
3. i need help with this c program with structs and...

# Question: i need help with this c program with structs and...

###### Question details

I need help with this c++ program with structs and functions

Fran came up with a new formula that rates the performance of a quarterback for a football game. Your job is to test her formula by writing a program to process quarterback data from a given input file. Assume the file is named football-in.txt. The file will contain data for an arbitrary number of quarterbacks. A quarterback's first and last names will appear on lines by themselves. His game data (attempts, completions, yards passing, touchdowns, and interceptions) will appear on the line below his last name. All numeric data will be integers. Assume there will not be more than 100 quarterbacks. A sample input file is shown on the reverse side of this sheet.

The program should compute the completion percentage and the quarterback rating and display it with the input data.

The program needs to include the following functions:

1. Read the data from the input file into an array of structs. Function name: readData
2. Compute and return the completion percentage (completions divided by attempts) given a quarterback struct (return zero if attempts is zero). Function name: computePercentage
3. Compute and return the quarterback rating given a quarterback struct (return zero if attempts is zero). Use the following formula for the quarterback rating: Function name: quaterbackRating

formula:  rating = (3 * completions + passingyards+10 * touchdowns) / (attempts + 8*intercepetions)

1. Display the data from the array of structs, along with the completion percentage and the quarterback rating. This function should call the two functions above (#2 and #3). The output should be displayed using formatted spacing and precision as shown on the next page. Use the setw command for alignment. Function name: diplayData

(5) A main driver function that will call functions #1 and #4.

Sample Input:

Dan

Marino

22 14 219 2 2

Terry

33 21 302 1 0

Roger

Staubach

24 12 244 0 1

Output: (the X's should be replaced with actual data)

Quarterback       Att.   Comp.   Pct.   Yards    TD   Int.   Rating

Dan Marino           XX XX     XX.X XXX X X XX.XX

Terry Bradshaw       XX XX     XX.X    XXX     X    X   XX.XX

Roger Staubach       XX    XX     XX.X    XXX    X     X   XX.XX