Pure Programmer
Blue Matrix


Cluster Map

Project: Sales Tax

Write a program that computes sales tax on a purchase amount. Also print the total sales amount including tax. Use a named constant for the sales tax rate at the top of the program and variables for the purchase amount, sales tax amount and total sale amount in the main part. Initially set sales tax rate to 8.0% and the purchase amount to $125.00. Then try changing the purchase amount and sales tax rate, then re-run the program.

Output
$ rustc SalesTax.rs error: unknown format trait `f` --> SalesTax.rs:14:46 | 14 | println!("{}", format!("Sales Amount: ${0:.2f}", salesAmount)); | ^ | = 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` --> SalesTax.rs:15:43 | 15 | println!("{}", format!("Sales Tax: ${0:.2f}", salesTax)); | ^ | = 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` --> SalesTax.rs:16:46 | 16 | println!("{}", format!("Total Amount: ${0:.2f}", total)); | ^ | = 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 --> SalesTax.rs:10:28 | 10 | let salesAmount:f64 = 125.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 10 | let salesAmount:f64 = 125.0f64; | + error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0610`.

Solution