Pure Programmer
Blue Matrix


Cluster Map

Project: Football Passer Rating (Revisited)

The passer rating formula provides one metric that can be used to compare the performance of quarterbacks. It is based on the number of completions, touchdown passes, interceptions and total passing yards. Write a program that prompts for the number of completed passes, touchdown passes, interceptions, total passing yards, the total number of attempted passes and whether the NFL or NCAA passer rating should be displayed. The program should call one of two functions to compute the NFL or NCAA passer rating. Print the rating to one decimal place.

See [[Passer Rating]] for the NFL and NCAA formulas.

See FootballPasserRating2

Output
$ rustc FootballPasserRating3.rs error: unknown format trait `f` --> FootballPasserRating3.rs:53:52 | 53 | println!("{}", format!("NFL 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: unknown format trait `f` --> FootballPasserRating3.rs:56:53 | 56 | println!("{}", format!("NCAA 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 --> FootballPasserRating3.rs:33:16 | 33 | inputStr = &(Utils.prompt("Number of attempts: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:36:16 | 36 | inputStr = &(Utils.prompt("Number of completions: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:39:16 | 39 | inputStr = &(Utils.prompt("Number of touchdown passes: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:42:16 | 42 | inputStr = &(Utils.prompt("Number of interceptions: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:45:16 | 45 | inputStr = &(Utils.prompt("Number of passing yards: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:48:16 | 48 | inputStr = &(Utils.prompt("1 for NFL or 2 for NCAA: ")); | ^^^^^ not found in this scope error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating3.rs:12:25 | 12 | 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 --> FootballPasserRating3.rs:12:50 | 12 | 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 --> FootballPasserRating3.rs:12:74 | 12 | 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 | 12 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.0f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating3.rs:13:25 | 13 | 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 --> FootballPasserRating3.rs:13:51 | 13 | 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 --> FootballPasserRating3.rs:13:65 | 13 | 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 | 13 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.0f64) * 0.25f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating3.rs:14:24 | 14 | 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 --> FootballPasserRating3.rs:14:53 | 14 | 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 --> FootballPasserRating3.rs:14:68 | 14 | 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 | 14 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.0f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating3.rs:15:36 | 15 | 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 --> FootballPasserRating3.rs:15:63 | 15 | 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 --> FootballPasserRating3.rs:15:78 | 15 | 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 | 15 | 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 --> FootballPasserRating3.rs:16:39 | 16 | 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 | 16 | let rating:f64 = (a + b + c + d) / 6.0f64 * 100.f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating3.rs:16:49 | 16 | 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 | 16 | let rating:f64 = (a + b + c + d) / 6.f64 * 100.0f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating3.rs:22:18 | 22 | let b:f64 = 330.f64 * (touchdownPasses) as f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 22 | let b:f64 = 330.0f64 * (touchdownPasses) as f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating3.rs:23:18 | 23 | let c:f64 = 100.f64 * (completions) as f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 23 | let c:f64 = 100.0f64 * (completions) as f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating3.rs:24:18 | 24 | let d:f64 = 200.f64 * (interceptions) as f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 24 | let d:f64 = 200.0f64 * (interceptions) as f64; | + error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:34:14 | 34 | attempts = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:37:17 | 37 | completions = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:40:21 | 40 | touchdownPasses = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:43:19 | 43 | interceptions = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:46:18 | 46 | passingYards = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:49:11 | 49 | which = stoi(inputStr)?; | ^^^^ not found in this scope error: aborting due to 31 previous errors Some errors have detailed explanations: E0277, E0425, E0610. For more information about an error, try `rustc --explain E0277`. $ rustc FootballPasserRating3.rs error: unknown format trait `f` --> FootballPasserRating3.rs:53:52 | 53 | println!("{}", format!("NFL 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: unknown format trait `f` --> FootballPasserRating3.rs:56:53 | 56 | println!("{}", format!("NCAA 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 --> FootballPasserRating3.rs:33:16 | 33 | inputStr = &(Utils.prompt("Number of attempts: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:36:16 | 36 | inputStr = &(Utils.prompt("Number of completions: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:39:16 | 39 | inputStr = &(Utils.prompt("Number of touchdown passes: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:42:16 | 42 | inputStr = &(Utils.prompt("Number of interceptions: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:45:16 | 45 | inputStr = &(Utils.prompt("Number of passing yards: ")); | ^^^^^ not found in this scope error[E0425]: cannot find value `Utils` in this scope --> FootballPasserRating3.rs:48:16 | 48 | inputStr = &(Utils.prompt("1 for NFL or 2 for NCAA: ")); | ^^^^^ not found in this scope error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating3.rs:12:25 | 12 | 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 --> FootballPasserRating3.rs:12:50 | 12 | 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 --> FootballPasserRating3.rs:12:74 | 12 | 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 | 12 | let a:f64 = (f64::from(completions) / f64::from(attempts) - 0.3f64) * 5.0f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating3.rs:13:25 | 13 | 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 --> FootballPasserRating3.rs:13:51 | 13 | 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 --> FootballPasserRating3.rs:13:65 | 13 | 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 | 13 | let b:f64 = (f64::from(passingYards) / f64::from(attempts) - 3.0f64) * 0.25f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating3.rs:14:24 | 14 | 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 --> FootballPasserRating3.rs:14:53 | 14 | 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 --> FootballPasserRating3.rs:14:68 | 14 | 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 | 14 | let c:f64 = f64::from(touchdownPasses) / f64::from(attempts) * 20.0f64; | + error[E0277]: the trait bound `f64: From<isize>` is not satisfied --> FootballPasserRating3.rs:15:36 | 15 | 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 --> FootballPasserRating3.rs:15:63 | 15 | 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 --> FootballPasserRating3.rs:15:78 | 15 | 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 | 15 | 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 --> FootballPasserRating3.rs:16:39 | 16 | 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 | 16 | let rating:f64 = (a + b + c + d) / 6.0f64 * 100.f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating3.rs:16:49 | 16 | 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 | 16 | let rating:f64 = (a + b + c + d) / 6.f64 * 100.0f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating3.rs:22:18 | 22 | let b:f64 = 330.f64 * (touchdownPasses) as f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 22 | let b:f64 = 330.0f64 * (touchdownPasses) as f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating3.rs:23:18 | 23 | let c:f64 = 100.f64 * (completions) as f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 23 | let c:f64 = 100.0f64 * (completions) as f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FootballPasserRating3.rs:24:18 | 24 | let d:f64 = 200.f64 * (interceptions) as f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 24 | let d:f64 = 200.0f64 * (interceptions) as f64; | + error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:34:14 | 34 | attempts = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:37:17 | 37 | completions = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:40:21 | 40 | touchdownPasses = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:43:19 | 43 | interceptions = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:46:18 | 46 | passingYards = stoi(inputStr)?; | ^^^^ not found in this scope error[E0425]: cannot find function `stoi` in this scope --> FootballPasserRating3.rs:49:11 | 49 | which = stoi(inputStr)?; | ^^^^ not found in this scope error: aborting due to 31 previous errors Some errors have detailed explanations: E0277, E0425, E0610. For more information about an error, try `rustc --explain E0277`.

Solution