Pure Programmer
Blue Matrix


Cluster Map

Project: Combined FICA Tax (Formatted)

Write a program that computes the Social Security and Medicare tax on your paycheck. Creates a floating point constant named FICA_RATE with the value 0.0765. Create constant for gross pay and variables for net pay and total FICA tax. Be sure to initialize your variables. The gross pay constant should be initialized to your weekly pay amount. Then compute the FICA tax by multiplying FICA_RATE by your gross pay (using * as the symbol for multiplication) to initialize the FICA tax variable. Then compute net pay by subtracting the FICA tax from gross pay. Print the gross pay, total FICA tax and net pay formatted to two decimal places.

See: CombinedFICATax

Output
$ rustc CombinedFICATaxFormatted.rs error: unknown format trait `f` --> CombinedFICATaxFormatted.rs:13:42 | 13 | println!("{}", format!("Gross Pay: {0:.2f}", GROSS_PAY)); | ^ | = 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` --> CombinedFICATaxFormatted.rs:14:41 | 14 | println!("{}", format!("FICA Tax: {0:.2f}", ficaTax)); | ^ | = 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` --> CombinedFICATaxFormatted.rs:15:40 | 15 | println!("{}", format!("Net Pay: {0:.2f}", netPay)); | ^ | = 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[E0308]: mismatched types --> CombinedFICATaxFormatted.rs:8:24 | 8 | static GROSS_PAY:f64 = 1000; | ^^^^ | | | expected `f64`, found integer | help: use a float literal: `1000.0` error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`.

Solution