In football, there is a statistic for quarterbacks called the passer rating. The
ID: 3676703 • Letter: I
Question
In football, there is a statistic for quarterbacks called the passer rating. There are five input parameters to the calculation: pass completions, pass attempts, totoal passing yards, touchdowns, and interceptions. Write a program with five user inputs:
I. Pass completions
II. Pass attempts
II. Total passing yards
IV. Touchdowns
V. Interceptions
Use the following cout statements to ask the user for input:
cout<<”Enter pass completions “<< endl;
cout<<”Enter pass completions “<<endl;
cout<<”Enter pass attempts “<<endl;
cout<<”Enter total yards “<<endl;
cout<<”Enter touchdowns “<<endl;
cout<<”Enter interceptions “<<endl;
Each of your cout statements needs to be followed by a cin statement to get
the user input.
Your five inputs should then be used in the passer rating calculation as
follows:
I. C = (completions per attempt -0.30)*5
II. Y = (yards per attempt – 3)*0.25
III. T = touchdowns per attempt*20
IV. I = 2.375 – (Intercepts per attempt * 25)
V. If C,Y,T, or I is less than 0, then set it to 0
VI. If C,Y,T, or I is greater than 2.375, then set it to 2.375
VII. PasserRating = (C + Y + T + I)/6*100
Once you have the calculations working, add an evaluation of the passer
rating. A rating is “poor” if it is 85 or below, “mediocre” if above 85, “good” if
above 90, and “great” if above 95. Output the passer rating, and whether the
rating is “poor”, “mediocre”, “good”, or “great”. For example, a print
statement for a passer rating of 65 would look like: “Rating 65, this is poor”.
This cout statement should be formatted as follows:
Cout<<”Rating “<<intRating<<”, this is poor”<<endl; *with proper term
substituted for the rating.
Explanation / Answer
Answer:)
#include <iostream.h>
int main()
{
int comp;
int pass_attempts;
double tot_yard;
int touch_down;
int intercep;
double C,Y,I, pass_rating, T;
int i;
cout<<"Enter the number of pass attempts::";
cin>>pass_attempts;
for(i=1;i<=pass_attempts;i++)
{
cout<<"Enter pass completion count for pass attemt "<<i<<"::";
cin>>comp;
cout<<"Enter the total yard for this attempt::";
cin>>tot_yard;
cout<<"Enter the number of touch downs for this attempt::";
cin>>touch_down;
cout<<"Enter intercepts for this attemp::";
cin>>intercep;
C = (comp - 0.30) * 5;
Y = (tot_yard - 3) * 0.25;
T = touch_down * 20;
I = 2.375 - (intercep * 25);
if((C<0) || (Y<0) || (T<0) || (I<0))
{
C=0;
Y=0;
T=0;
I=0;
}
if((C>2.375) || (Y>2.375) || (T>2.375) || (I>2.375))
{
C = 2.375;
Y = 2.375;
T = 2.375;
I = 2.375;
}
pass_rating = (C+Y+T+I)/6 * 100;
if(pass_rating <= 85.00)
{
cout<<"Passer Rating is "<<pass_rating<<". This is POOR. ";
}
else
{
if(pass_rating <= 90.00)
cout<<"Passer Rating is "<<pass_rating<<". This is MEDIOCRE. ";
else
{
if(pass_rating <= 95.00)
cout<<"Passer Rating is "<<pass_rating<<". This is GOOD. ";
else
cout<<"Passer Rating is "<<pass_rating<<". This is GREAT. ";
}
}
}
}