Luan Vo

Greenhorn

Posts: 8

posted 4 years ago

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

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

Luan Vo

Greenhorn

Posts: 8

Tony Docherty

Bartender

Posts: 3271

82

posted 4 years ago

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

etc

posted 4 years ago

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.

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

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

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