programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

Calculation need help

Luan Vo
Greenhorn
Posts: 8

The problem: Since football season is starting, you will write a program to perform one of the more mathematically tedious calculations in sports – the NFL Passer Rating System. A reward is that you will be one of the few people in Phoenix that understands when the announcers talk about the “Quarterback Ratings.”

The calculation: A Quarterback earns a statistical “Passer Rating” based on 5 different statistics. There are many web sites that show how to calculate this. You can google “NFL Passer Rating” or follow my instructions below. The Wikipedia entry shows the steps in more of a formula, but my instructions (taken from these sites) does not assume any football knowledge.

The NFL Passer Rating is based on 5 numbers:
The number of passing attempts (att)
The number of completions (comp)
The number of yards gained (yds)
The number of touchdowns (tds)
The number of interceptions (ints)

1. Calculate an adjusted Percentage of Completions: calculate completions/attempts, being sure it is multiplied by 100 to get a percentage. Subtract 30 from the result and then multiply the result by 0.05. But…it has to be between zero and 2.375, so if the result is less than zero, change it to zero; if the result is greater than 2.375, change it to 2.375. I suggest you store the result in a variable to use later.

2. Calculate an adjusted Average Yards Gained Per Attempt: calculate the yards/attempts (do not multiply by 100). Subtract 3 yards and then multiply the result by 0.25. But…it has to be between zero and 2.375, so if the result is less than zero, change it to zero; if the result is greater than 2.375, change it to 2.375. I suggest you store the result in another variable to use later.

3. Calculate an adjusted Percentage of Touchdown Passes: calculate tds/attempt, being sure it is multiplied by 100 to get a percentage. Multiply the result by 0.2. But…it has to be between zero and 2.375, so if the result is greater than 2.375, change it to 2.375. I suggest you store the result in another variable to use later.

4. Calculate an adjusted Percentage of Interceptions: calculate intercepts/attempt, being sure it is multiplied by 100 to get a percentage. Multiply the interception percentage by 0.25 and then subtract the result from 2.375. But…it has to be between zero and 2.375, so if the result is less than zero, change it to zero. I suggest you store the result in another variable to use later.

5. Add the previous 4 calculations, divide by 6, and multiply by 100 to get the Passer Rating.
Can youguys help me to write this calculation because im lost

Tony Docherty
Bartender
Posts: 3271
82
Which bit are you stuck on?

Luan Vo
Greenhorn
Posts: 8
Tony Docherty wrote:Which bit are you stuck on?

Im confuse with the number 1 calculation. Like i don't know how to set it up.

Tony Docherty
Bartender
Posts: 3271
82
Ok, so presumably you have the code to input the 5 values and store them in five suitably named variables. Now the follow the instructions step by step. If it is too confusing to do all the calculations on one line break it into individual calculations and store intermediate results in temporary variables. For example:
etc

fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
One thing all developers need to learn is that before you write a SINGLE line of code, you have to understand what you are supposed to do. you should be able to do the entire problem with paper/pencil before you write code.

I think it is Winston who always says that programming is 90% THINKING, and 10% writing lines of code.

 Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters?