Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Bradshaw

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

8. Explain the contact hypothesis.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago