Project: Income Tax (Revisited)
US Income Tax is calculated based on brackets. Write a program that uses the tables below to calculate the 2020 income tax. The program should accept two command line arguments. The first is the taxable income amount. The second is the tax table to use either S, M or H for single, married or head-of-household respectively. Make the program easy to update by storing the bracket information in arrays at the beginning of the program.
Rate | Taxable Income Bracket | Tax Owed |
---|---|---|
10% |
$0 to $9,875 | 10% of Taxable Income |
12% |
$9,876 to $40,125 | Maximum tax from previous bracket plus 12% of the excess over $9,875 |
22% |
$40,126 to $85,525 | Maximum tax from previous bracket plus 22% of the excess over $40,125 |
24% |
$85,526 to $163,300 | Maximum tax from previous bracket plus 24% of the excess over $85,525 |
32% |
$163,301 to $207,350 | Maximum tax from previous bracket plus 32% of the excess over $163,300 |
35% |
$207,351 to $518,400 | Maximum tax from previous bracket plus 35% of the excess over $207,350 |
37% |
$518,401+ | Maximum tax from previous bracket plus 37% of the excess over $518,400 |
Rate | Taxable Income Bracket | Tax Owed |
---|---|---|
10% |
$0 to $19,750 | 10% of Taxable Income |
12% |
$19,751 to $80,250 | Maximum tax from previous bracket plus 12% of the excess over $19,750 |
22% |
$80,251 to $171,050 | Maximum tax from previous bracket plus 22% of the excess over $80,250 |
24% |
$171,051 to $326,600 | Maximum tax from previous bracket plus 24% of the excess over $171,050 |
32% |
$326,601 to $414,700 | Maximum tax from previous bracket plus 32% of the excess over $326,600 |
35% |
$414,701 to $622,050 | Maximum tax from previous bracket plus 35% of the excess over $414,700 |
37% |
$622,051+ | Maximum tax from previous bracket plus 37% of the excess over $622,050 |
Rate | Taxable Income Bracket | Tax Owed |
---|---|---|
10% |
$0 to $14,100 | 10% of Taxable Income |
12% |
$14,101 to $53,700 | Maximum tax from previous bracket plus 12% of the excess over $14,100 |
22% |
$53,701 to $85,500 | Maximum tax from previous bracket plus 22% of the excess over $53,700 |
24% |
$85,501 to $163,300 | Maximum tax from previous bracket plus 24% of the excess over $85,500 |
32% |
$163,301 to $207,350 | Maximum tax from previous bracket plus 32% of the excess over $163,300 |
35% |
$207,351 to $518,400 | Maximum tax from previous bracket plus 35% of the excess over $207,350 |
37% |
$518,401+ | Maximum tax from previous bracket plus 37% of the excess over $518,400 |
Source: [[Federal Income Tax Brackets]]
Output
$ rustc IncomeTax3.rs
error: unknown format trait `s`
--> IncomeTax3.rs:24:38
|
24 | println!("{}", format!("Syntax: {0:s} income S|M|H", 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`
--> IncomeTax3.rs:53:52
|
53 | println!("{}", format!("Federal Income Tax: ${0:.2f}", incomeTax));
| ^
|
= 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 `Utils` in this scope
--> IncomeTax3.rs:21:12
|
21 | income = Utils.stodWithDefault(args[1], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find function `exit` in this scope
--> IncomeTax3.rs:25:3
|
25 | exit(1);
| ^^^^ not found in this scope
|
help: consider importing this function
|
8 + use std::process::exit;
|
error[E0308]: mismatched types
--> IncomeTax3.rs:11:45
|
11 | static mut singleBracketMax:Vec<f64> = vec![9875, 40125, 85525, 163300, 207350, 518400];
| ^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `9875.0`
error[E0308]: mismatched types
--> IncomeTax3.rs:12:46
|
12 | static mut marriedBracketMax:Vec<f64> = vec![19750, 80250, 171050, 326600, 326600, 326600];
| ^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `19750.0`
error[E0308]: mismatched types
--> IncomeTax3.rs:13:48
|
13 | static mut householdBracketMax:Vec<f64> = vec![14100, 53700, 85500, 163300, 207350, 518400];
| ^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `14100.0`
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:17:25
|
17 | let mut income:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
17 | let mut income:f64 = 0.0f64;
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:19:28
|
19 | let mut incomeTax:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
19 | let mut incomeTax:f64 = 0.0f64;
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:35:33
|
35 | let mut lastBracketMax:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
35 | let mut lastBracketMax:f64 = 0.0f64;
| +
error[E0308]: mismatched types
--> IncomeTax3.rs:38:13
|
38 | while i < bracketMax.len() {
| - ^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
| |
| expected because this is `isize`
|
help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit
|
38 | while i < bracketMax.len().try_into().unwrap() {
| ++++++++++++++++++++
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:39:28
|
39 | if income <= bracketMax[i] {
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:40:55
|
40 | incomeTax += (income - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:43:30
|
43 | incomeTax += (bracketMax[i] - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:43:62
|
43 | incomeTax += (bracketMax[i] - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:44:33
|
44 | lastBracketMax = bracketMax[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error: aborting due to 16 previous errors
Some errors have detailed explanations: E0277, E0308, E0425, E0610.
For more information about an error, try `rustc --explain E0277`.
$ rustc IncomeTax3.rs
error: unknown format trait `s`
--> IncomeTax3.rs:24:38
|
24 | println!("{}", format!("Syntax: {0:s} income S|M|H", 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`
--> IncomeTax3.rs:53:52
|
53 | println!("{}", format!("Federal Income Tax: ${0:.2f}", incomeTax));
| ^
|
= 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 `Utils` in this scope
--> IncomeTax3.rs:21:12
|
21 | income = Utils.stodWithDefault(args[1], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find function `exit` in this scope
--> IncomeTax3.rs:25:3
|
25 | exit(1);
| ^^^^ not found in this scope
|
help: consider importing this function
|
8 + use std::process::exit;
|
error[E0308]: mismatched types
--> IncomeTax3.rs:11:45
|
11 | static mut singleBracketMax:Vec<f64> = vec![9875, 40125, 85525, 163300, 207350, 518400];
| ^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `9875.0`
error[E0308]: mismatched types
--> IncomeTax3.rs:12:46
|
12 | static mut marriedBracketMax:Vec<f64> = vec![19750, 80250, 171050, 326600, 326600, 326600];
| ^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `19750.0`
error[E0308]: mismatched types
--> IncomeTax3.rs:13:48
|
13 | static mut householdBracketMax:Vec<f64> = vec![14100, 53700, 85500, 163300, 207350, 518400];
| ^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `14100.0`
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:17:25
|
17 | let mut income:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
17 | let mut income:f64 = 0.0f64;
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:19:28
|
19 | let mut incomeTax:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
19 | let mut incomeTax:f64 = 0.0f64;
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:35:33
|
35 | let mut lastBracketMax:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
35 | let mut lastBracketMax:f64 = 0.0f64;
| +
error[E0308]: mismatched types
--> IncomeTax3.rs:38:13
|
38 | while i < bracketMax.len() {
| - ^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
| |
| expected because this is `isize`
|
help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit
|
38 | while i < bracketMax.len().try_into().unwrap() {
| ++++++++++++++++++++
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:39:28
|
39 | if income <= bracketMax[i] {
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:40:55
|
40 | incomeTax += (income - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:43:30
|
43 | incomeTax += (bracketMax[i] - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:43:62
|
43 | incomeTax += (bracketMax[i] - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:44:33
|
44 | lastBracketMax = bracketMax[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error: aborting due to 16 previous errors
Some errors have detailed explanations: E0277, E0308, E0425, E0610.
For more information about an error, try `rustc --explain E0277`.
$ rustc IncomeTax3.rs
error: unknown format trait `s`
--> IncomeTax3.rs:24:38
|
24 | println!("{}", format!("Syntax: {0:s} income S|M|H", 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`
--> IncomeTax3.rs:53:52
|
53 | println!("{}", format!("Federal Income Tax: ${0:.2f}", incomeTax));
| ^
|
= 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 `Utils` in this scope
--> IncomeTax3.rs:21:12
|
21 | income = Utils.stodWithDefault(args[1], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find function `exit` in this scope
--> IncomeTax3.rs:25:3
|
25 | exit(1);
| ^^^^ not found in this scope
|
help: consider importing this function
|
8 + use std::process::exit;
|
error[E0308]: mismatched types
--> IncomeTax3.rs:11:45
|
11 | static mut singleBracketMax:Vec<f64> = vec![9875, 40125, 85525, 163300, 207350, 518400];
| ^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `9875.0`
error[E0308]: mismatched types
--> IncomeTax3.rs:12:46
|
12 | static mut marriedBracketMax:Vec<f64> = vec![19750, 80250, 171050, 326600, 326600, 326600];
| ^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `19750.0`
error[E0308]: mismatched types
--> IncomeTax3.rs:13:48
|
13 | static mut householdBracketMax:Vec<f64> = vec![14100, 53700, 85500, 163300, 207350, 518400];
| ^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `14100.0`
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:17:25
|
17 | let mut income:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
17 | let mut income:f64 = 0.0f64;
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:19:28
|
19 | let mut incomeTax:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
19 | let mut incomeTax:f64 = 0.0f64;
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:35:33
|
35 | let mut lastBracketMax:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
35 | let mut lastBracketMax:f64 = 0.0f64;
| +
error[E0308]: mismatched types
--> IncomeTax3.rs:38:13
|
38 | while i < bracketMax.len() {
| - ^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
| |
| expected because this is `isize`
|
help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit
|
38 | while i < bracketMax.len().try_into().unwrap() {
| ++++++++++++++++++++
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:39:28
|
39 | if income <= bracketMax[i] {
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:40:55
|
40 | incomeTax += (income - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:43:30
|
43 | incomeTax += (bracketMax[i] - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:43:62
|
43 | incomeTax += (bracketMax[i] - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:44:33
|
44 | lastBracketMax = bracketMax[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error: aborting due to 16 previous errors
Some errors have detailed explanations: E0277, E0308, E0425, E0610.
For more information about an error, try `rustc --explain E0277`.
$ rustc IncomeTax3.rs
error: unknown format trait `s`
--> IncomeTax3.rs:24:38
|
24 | println!("{}", format!("Syntax: {0:s} income S|M|H", 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`
--> IncomeTax3.rs:53:52
|
53 | println!("{}", format!("Federal Income Tax: ${0:.2f}", incomeTax));
| ^
|
= 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 `Utils` in this scope
--> IncomeTax3.rs:21:12
|
21 | income = Utils.stodWithDefault(args[1], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find function `exit` in this scope
--> IncomeTax3.rs:25:3
|
25 | exit(1);
| ^^^^ not found in this scope
|
help: consider importing this function
|
8 + use std::process::exit;
|
error[E0308]: mismatched types
--> IncomeTax3.rs:11:45
|
11 | static mut singleBracketMax:Vec<f64> = vec![9875, 40125, 85525, 163300, 207350, 518400];
| ^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `9875.0`
error[E0308]: mismatched types
--> IncomeTax3.rs:12:46
|
12 | static mut marriedBracketMax:Vec<f64> = vec![19750, 80250, 171050, 326600, 326600, 326600];
| ^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `19750.0`
error[E0308]: mismatched types
--> IncomeTax3.rs:13:48
|
13 | static mut householdBracketMax:Vec<f64> = vec![14100, 53700, 85500, 163300, 207350, 518400];
| ^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `14100.0`
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:17:25
|
17 | let mut income:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
17 | let mut income:f64 = 0.0f64;
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:19:28
|
19 | let mut incomeTax:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
19 | let mut incomeTax:f64 = 0.0f64;
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> IncomeTax3.rs:35:33
|
35 | let mut lastBracketMax:f64 = 0.f64;
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
35 | let mut lastBracketMax:f64 = 0.0f64;
| +
error[E0308]: mismatched types
--> IncomeTax3.rs:38:13
|
38 | while i < bracketMax.len() {
| - ^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
| |
| expected because this is `isize`
|
help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit
|
38 | while i < bracketMax.len().try_into().unwrap() {
| ++++++++++++++++++++
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:39:28
|
39 | if income <= bracketMax[i] {
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:40:55
|
40 | incomeTax += (income - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:43:30
|
43 | incomeTax += (bracketMax[i] - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:43:62
|
43 | incomeTax += (bracketMax[i] - lastBracketMax) * taxRates[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error[E0277]: the type `[f64]` cannot be indexed by `isize`
--> IncomeTax3.rs:44:33
|
44 | lastBracketMax = bracketMax[i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[f64]>` is not implemented for `isize`
= help: the trait `SliceIndex<[T]>` is implemented for `usize`
= note: required for `Vec<f64>` to implement `Index<isize>`
error: aborting due to 16 previous errors
Some errors have detailed explanations: E0277, E0308, E0425, E0610.
For more information about an error, try `rustc --explain E0277`.