Pure Programmer
Blue Matrix


Cluster Map

Project: FICA Taxes (Revisited)

The Federal Insurance Contributions Act (FICA) is made up of two items, Social Security and Medicare taxes. For 2020, the Social Security tax rate is 6.2% on the first $137,700 wages paid. The Medicare tax rate is 1.45% on the first $200,000 and 2.35% on wages above $200,000. Write a program that computes the annual taxes for someone who earns an annual salary provided on the command line. Print the annual salary, Social Security tax, Medicare tax and then the final net salary (annual salary minus taxes). Test the program on annual salaries of $60,000, $140,000 and $210,000.

Output
$ rustc FICA2.rs error: unknown format trait `s` --> FICA2.rs:17:38 | 17 | println!("{}", format!("Syntax: {0:s} annual_salary", utils::program_name().expect("program name should not be empty!"))); | ^ | = 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` --> FICA2.rs:39:46 | 39 | println!("{}", format!("Gross Salary: ${0:.2f}", annualSalary)); | ^ | = 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` --> FICA2.rs:40:53 | 40 | println!("{}", format!("Social Security Tax: ${0:.2f}", ssTax)); | ^ | = 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` --> FICA2.rs:41:46 | 41 | println!("{}", format!("Medicare Tax: ${0:.2f}", medicareTax)); | ^ | = 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` --> FICA2.rs:42:44 | 42 | println!("{}", format!("Net Salary: ${0:.2f}", netSalary)); | ^ | = 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 `args` in this scope --> FICA2.rs:16:5 | 16 | if args.len() != 2 { | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::env::args; | error[E0425]: cannot find function `exit` in this scope --> FICA2.rs:18:3 | 18 | exit(1); | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::process::exit; | error[E0425]: cannot find value `Utils` in this scope --> FICA2.rs:21:25 | 21 | let annualSalary:f64 = Utils.stodWithDefault(args[1], 0.0f64); | ^^^^^ not found in this scope error[E0425]: cannot find value `args` in this scope --> FICA2.rs:21:47 | 21 | let annualSalary:f64 = Utils.stodWithDefault(args[1], 0.0f64); | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::env::args; | error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0425`. $ rustc FICA2.rs error: unknown format trait `s` --> FICA2.rs:17:38 | 17 | println!("{}", format!("Syntax: {0:s} annual_salary", utils::program_name().expect("program name should not be empty!"))); | ^ | = 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` --> FICA2.rs:39:46 | 39 | println!("{}", format!("Gross Salary: ${0:.2f}", annualSalary)); | ^ | = 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` --> FICA2.rs:40:53 | 40 | println!("{}", format!("Social Security Tax: ${0:.2f}", ssTax)); | ^ | = 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` --> FICA2.rs:41:46 | 41 | println!("{}", format!("Medicare Tax: ${0:.2f}", medicareTax)); | ^ | = 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` --> FICA2.rs:42:44 | 42 | println!("{}", format!("Net Salary: ${0:.2f}", netSalary)); | ^ | = 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 `args` in this scope --> FICA2.rs:16:5 | 16 | if args.len() != 2 { | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::env::args; | error[E0425]: cannot find function `exit` in this scope --> FICA2.rs:18:3 | 18 | exit(1); | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::process::exit; | error[E0425]: cannot find value `Utils` in this scope --> FICA2.rs:21:25 | 21 | let annualSalary:f64 = Utils.stodWithDefault(args[1], 0.0f64); | ^^^^^ not found in this scope error[E0425]: cannot find value `args` in this scope --> FICA2.rs:21:47 | 21 | let annualSalary:f64 = Utils.stodWithDefault(args[1], 0.0f64); | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::env::args; | error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0425`. $ rustc FICA2.rs error: unknown format trait `s` --> FICA2.rs:17:38 | 17 | println!("{}", format!("Syntax: {0:s} annual_salary", utils::program_name().expect("program name should not be empty!"))); | ^ | = 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` --> FICA2.rs:39:46 | 39 | println!("{}", format!("Gross Salary: ${0:.2f}", annualSalary)); | ^ | = 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` --> FICA2.rs:40:53 | 40 | println!("{}", format!("Social Security Tax: ${0:.2f}", ssTax)); | ^ | = 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` --> FICA2.rs:41:46 | 41 | println!("{}", format!("Medicare Tax: ${0:.2f}", medicareTax)); | ^ | = 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` --> FICA2.rs:42:44 | 42 | println!("{}", format!("Net Salary: ${0:.2f}", netSalary)); | ^ | = 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 `args` in this scope --> FICA2.rs:16:5 | 16 | if args.len() != 2 { | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::env::args; | error[E0425]: cannot find function `exit` in this scope --> FICA2.rs:18:3 | 18 | exit(1); | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::process::exit; | error[E0425]: cannot find value `Utils` in this scope --> FICA2.rs:21:25 | 21 | let annualSalary:f64 = Utils.stodWithDefault(args[1], 0.0f64); | ^^^^^ not found in this scope error[E0425]: cannot find value `args` in this scope --> FICA2.rs:21:47 | 21 | let annualSalary:f64 = Utils.stodWithDefault(args[1], 0.0f64); | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::env::args; | error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0425`.

Solution