Pure Programmer
Blue Matrix


Cluster Map

Project: Supermarket Sale

A supermarket is having a sale on 2-liter bottles of soda: 3 for $2.99. Write a program that prints the price for 1 through 12 bottles of soda. Remember to round prices to dollars and cents.

Output
$ rustc SupermarketSale1.rs error: unknown format trait `d` --> SupermarketSale1.rs:13:31 | 13 | println!("{}", format!("{0:d} bottle(s) is ${1:.2f}", i, (i) as f64 * price)); | ^ | = 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` --> SupermarketSale1.rs:13:53 | 13 | println!("{}", format!("{0:d} bottle(s) is ${1:.2f}", i, (i) as f64 * price)); | ^ | = 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: aborting due to 2 previous errors

Solution