Pure Programmer
Blue Matrix


Cluster Map

Project: Quadradic Equations

Write a program that computes the value of the [[quadratic equation]] y = ax² + bx + c. Used named constants for a, b and c and use variables for x and y. Initially set a, b and c to 3, 2 and 1 respectively then print out y for x = 0,1,2 and 3. Use the increment operator ++ to change your x variable before each successive computation of y. Then try changing the values of a, b and c to compute different quadratic equation.

Output
$ rustc QuadraticEquations.rs error: unknown format trait `g` --> QuadraticEquations.rs:14:33 | 14 | println!("{}", format!("f({0:.6g}) = {1:.6g}", x, y)); | ^ | = 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 `g` --> QuadraticEquations.rs:14:44 | 14 | println!("{}", format!("f({0:.6g}) = {1:.6g}", x, y)); | ^ | = 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 `g` --> QuadraticEquations.rs:18:33 | 18 | println!("{}", format!("f({0:.6g}) = {1:.6g}", x, y)); | ^ | = 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 `g` --> QuadraticEquations.rs:18:44 | 18 | println!("{}", format!("f({0:.6g}) = {1:.6g}", x, y)); | ^ | = 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 `g` --> QuadraticEquations.rs:22:33 | 22 | println!("{}", format!("f({0:.6g}) = {1:.6g}", x, y)); | ^ | = 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 `g` --> QuadraticEquations.rs:22:44 | 22 | println!("{}", format!("f({0:.6g}) = {1:.6g}", x, y)); | ^ | = 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 `g` --> QuadraticEquations.rs:26:33 | 26 | println!("{}", format!("f({0:.6g}) = {1:.6g}", x, y)); | ^ | = 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 `g` --> QuadraticEquations.rs:26:44 | 26 | println!("{}", format!("f({0:.6g}) = {1:.6g}", x, y)); | ^ | = 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[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> QuadraticEquations.rs:7:18 | 7 | static A:f64 = 3.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 7 | static A:f64 = 3.0f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> QuadraticEquations.rs:8:18 | 8 | static B:f64 = 2.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 8 | static B:f64 = 2.0f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> QuadraticEquations.rs:9:18 | 9 | static C:f64 = 1.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 9 | static C:f64 = 1.0f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> QuadraticEquations.rs:12:20 | 12 | let mut x:f64 = 0.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 12 | let mut x:f64 = 0.0f64; | + error: aborting due to 12 previous errors For more information about this error, try `rustc --explain E0610`.

Solution