Pure Programmer
Blue Matrix


Cluster Map

Project: Football Passer Rating (NFL)

In US football quarterbacks are rated on their performance based on a specific formula that combines statistics such as number of passing yards, number of touchdowns and number of interceptions. In the NFL the professional football passer rating formula is:






where

ATT
Number of passing attempts
COMP
Number of completions
YDS
Passing yards
TD
Touchdown passes
INT
Interceptions

Source: [[Passer Rating]]

The program should prompt the user for the five input values above and print the passer rating to one decimal place.

See: [[NFL Player Statistics]] for actual statistics that you can test with.

Output
$ rustc FootballPasserRating1.rs error: unknown format trait `f` --> FootballPasserRating1.rs:35:47 | 35 | println!("{}", format!("Passer rating: {0:.1f}", rating)); | ^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:15:16 | 15 | inputStr = &(Utils.prompt("Number of attempts: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:18:16 | 18 | inputStr = &(Utils.prompt("Number of completions: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:21:16 | 21 | inputStr = &(Utils.prompt("Number of touchdown passes: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:24:16 | 24 | inputStr = &(Utils.prompt("Number of interceptions: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:27:16 | 27 | inputStr = &(Utils.prompt("Number of passing yards: ")); | ^^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:16:14 | 16 | attempts = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:19:17 | 19 | completions = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:22:21 | 22 | touchdownPasses = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:25:19 | 25 | interceptions = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:28:18 | 28 | passingYards = stoi(inputStr)?; | ^^^^ not found in this scope error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:30:26 | 30 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.f64; | --------- ^^^^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:30:51 | 30 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.f64; | --------- ^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:30:75 | 30 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 30 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.0f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:31:26 | 31 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.f64) * 0.25f64; | --------- ^^^^^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:31:52 | 31 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.f64) * 0.25f64; | --------- ^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:31:66 | 31 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.f64) * 0.25f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 31 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.0f64) * 0.25f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:32:25 | 32 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.f64; | --------- ^^^^^^^^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:32:54 | 32 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.f64; | --------- ^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:32:69 | 32 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 32 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.0f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:33:37 | 33 | let d:f64 = 2.375f64 - (f64::from(interceptions) / f64::from(attempts) * 25.f64); | --------- ^^^^^^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:33:64 | 33 | let d:f64 = 2.375f64 - (f64::from(interceptions) / f64::from(attempts) * 25.f64); | --------- ^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:33:79 | 33 | let d:f64 = 2.375f64 - (f64::from(interceptions) / f64::from(attempts) * 25.f64); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 33 | let d:f64 = 2.375f64 - (f64::from(interceptions) / f64::from(attempts) * 25.0f64); | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:34:40 | 34 | let rating:f64 = (a + b + c + d) / 6.f64 * 100.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 34 | let rating:f64 = (a + b + c + d) / 6.0f64 * 100.f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:34:50 | 34 | let rating:f64 = (a + b + c + d) / 6.f64 * 100.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 34 | let rating:f64 = (a + b + c + d) / 6.f64 * 100.0f64; | + error: aborting due to 25 previous errors Some errors have detailed explanations: E0277, E0425, E0610. For more information about an error, try `rustc --explain E0277`. $ rustc FootballPasserRating1.rs error: unknown format trait `f` --> FootballPasserRating1.rs:35:47 | 35 | println!("{}", format!("Passer rating: {0:.1f}", rating)); | ^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:15:16 | 15 | inputStr = &(Utils.prompt("Number of attempts: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:18:16 | 18 | inputStr = &(Utils.prompt("Number of completions: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:21:16 | 21 | inputStr = &(Utils.prompt("Number of touchdown passes: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:24:16 | 24 | inputStr = &(Utils.prompt("Number of interceptions: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating1.rs:27:16 | 27 | inputStr = &(Utils.prompt("Number of passing yards: ")); | ^^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:16:14 | 16 | attempts = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:19:17 | 19 | completions = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:22:21 | 22 | touchdownPasses = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:25:19 | 25 | interceptions = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating1.rs:28:18 | 28 | passingYards = stoi(inputStr)?; | ^^^^ not found in this scope error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:30:26 | 30 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.f64; | --------- ^^^^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:30:51 | 30 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.f64; | --------- ^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:30:75 | 30 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 30 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.0f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:31:26 | 31 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.f64) * 0.25f64; | --------- ^^^^^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:31:52 | 31 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.f64) * 0.25f64; | --------- ^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:31:66 | 31 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.f64) * 0.25f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 31 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.0f64) * 0.25f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:32:25 | 32 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.f64; | --------- ^^^^^^^^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:32:54 | 32 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.f64; | --------- ^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:32:69 | 32 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 32 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.0f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:33:37 | 33 | let d:f64 = 2.375f64 - (f64::from(interceptions) / f64::from(attempts) * 25.f64); | --------- ^^^^^^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating1.rs:33:64 | 33 | let d:f64 = 2.375f64 - (f64::from(interceptions) / f64::from(attempts) * 25.f64); | --------- ^^^^^^^^ the trait `From<isize>` is not implemented for `f64` | | | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: <f64 as From<bool>> <f64 as From<f32>> <f64 as From<i16>> <f64 as From<i32>> <f64 as From<i8>> <f64 as From<u16>> <f64 as From<u32>> <f64 as From<u8>> error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:33:79 | 33 | let d:f64 = 2.375f64 - (f64::from(interceptions) / f64::from(attempts) * 25.f64); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 33 | let d:f64 = 2.375f64 - (f64::from(interceptions) / f64::from(attempts) * 25.0f64); | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:34:40 | 34 | let rating:f64 = (a + b + c + d) / 6.f64 * 100.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 34 | let rating:f64 = (a + b + c + d) / 6.0f64 * 100.f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating1.rs:34:50 | 34 | let rating:f64 = (a + b + c + d) / 6.f64 * 100.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 34 | let rating:f64 = (a + b + c + d) / 6.f64 * 100.0f64; | + error: aborting due to 25 previous errors Some errors have detailed explanations: E0277, E0425, E0610. For more information about an error, try `rustc --explain E0277`.

Solution