How to Calculate and Displays NFL Passer Rating? : <p>I am trying to do this homework problem but I am having difficulties setting it up and understanding how to start and accomplish these results.</p>

<p>This is the screenshot of the formulas:</p>

<p><img src="https://screenshot.net/pdg9piy?" alt="screenshot of the formulas"></p>

<p>[link if the image is not showing] <a href="https://screenshot.net/pdg9piy?" rel="nofollow noreferrer">https://screenshot.net/pdg9piy?</a></p>

<p>So far I've declared the variables for the formulas, created a scanner and tried to write the formula.
This is what I have so far:</p>

<pre><code>  //declaring variables
  float a_CompletionPercentage, b_YardsPerAttempt, c_TouchdownsPerAttempt, d_InterceptionsPerAttempt;
  float PasserRating;
  double Completion, Attempts, Touchdowns, Yards, Interceptions;


  Scanner in = new Scanner(System.in); //create Scanner Object


  //PlayerName input
  System.out.print("Enter the full name of the quarterback: "); //prompt asks for player name
  String PlayerName = in.nextLine(); //set string PlayerName as user's input

  //attempts input
  System.out.print("Enter the number of attempts: "); //prompt asks for # of attempts
  Attempts = in.nextDouble(); //set variable Attempts as user's input for # of attempts

  //completion input
  System.out.print("Enter the number of completions: "); 
  Completion = in.nextDouble(); 

  //yards input
  System.out.print("Enter the number of yards: "); 
  Yards = in.nextDouble();

  //touchdowns input
  System.out.print("Enter the number of touchdowns: "); 
  Touchdowns = in.nextDouble(); 

  //interceptions input
  System.out.print("Enter the number of interceptions: "); 
  Interceptions = in.nextDouble(); 

  //calculations 
  a_CompletionPercentage = (((float)(Completion/Attempts)- 0.3f) * 5f); //formula for completion percentage
  b_YardsPerAttempt = (((float)(Yards/Attempts)- 3f) * 5f); //formula for yards per attempt
  c_TouchdownsPerAttempt = ((float)(Touchdowns/Attempts) * 20f); //formula for touchdowns per attempt
  d_InterceptionsPerAttempt = (2.375f - ((float)(Interceptions/Attempts) * 25f)); //formula for interceptions per attempt

  PasserRating = (((a_CompletionPercentage + b_YardsPerAttempt + c_TouchdownsPerAttempt + d_InterceptionsPerAttempt)/6)*100f); //formula for passing rate


  //Displays result
  System.out.println("The passer rating for " + PlayerName + " is " + PasserRating);
</code></pre>

<p>I am not sure if my variables were declared correctly and my formula is not working.</p>

<p>These are some sample outputs that I should be getting:
Output Sample 1:</p>

<p>Enter the full name of the quarterback: Jameis Winston</p>

<p>Enter the number of attempts: 35</p>

<p>Enter the number of completions: 22</p>

<p>Enter the number of yards: 345</p>

<p>Enter the number of touchdowns: 4</p>

<p>Enter the number of interceptions: 1</p>

<p>The passer rating for Jameis Winston is 121.72619047619047</p>

<p>But I am getting 664.58325 and not 121.72619047619047.</p>

<p>PLEASE HELP!</p>

<p>THANK YOU SO MUCH FOR ANYONE THAT TAKES THE TIME TO HELP ME WITH THIS!</p>
