Passer rating, quarterback rating, or QB rating (passing efficency in college) is a measure of the performance of passers, primarily quarterbacks, in American football. There are two formulae currently in use: one used by both the National Football League (NFL) and Canadian Football League (CFL), and the other used in NCAA football. Passer rating is calculated using a player's passing attempts, completions, yards, touchdowns, and interceptions. Since 1973, passer rating has been the official formula used by the NFL to determine its passing leader. Quarterback rating in the NFL is on a scale from 0 to 158.3. Passing efficiency in college football is on a scale from −731.6 to 1261.6.

if (model.league == "nfl")
{
double a = ((model.comp / model.att) - 0.3) * 5; //part 1 of formula
double b = ((model.yds / model.att - 3) * 0.25); //part 2 of formula
double c = ((model.td / model.att) * 20); // part 3 of formula
double d = 2.375 - ((model.inter / model.att) * 25); //part 4 of formula
/*
* NFL QBR requires the result of any calculation to be non-negative and no more than 2.375
* It also states, if it is a negative number, set it to 0
* or if it's greater than 2.375, set it to 2.375
*/
a = Math.Max(a, 0);
b = Math.Max(b, 0);
c = Math.Max(c, 0);
d = Math.Max(d, 0);
a = Math.Min(a, 2.375);
b = Math.Min(b, 2.375);
c = Math.Min(c, 2.375);
d = Math.Min(d, 2.375);
var rating = (((a + b + c + d) / 6) * 100);
model.QBR = Math.Round(rating, 1);
var result = model.QBR.ToString();
ViewBag.result = $"The NFL QB Rating is: {result}";
}
else
{
//The NCAA doesn't have a minimum or maximum limit,
var rating = (((8.4 * model.yds) + (330 * model.td) + (100 * model.comp) - (200 * model.inter)) / model.att);
model.QBR = Math.Round(rating, 1);
var result = model.QBR.ToString();
ViewBag.result = $"The NCAA QB Rating is: {result}";
}