fn compute_tax(income: i32, status: &str, state: char) -> Result<f64, &str> {

    let mut rate = if status.eq_ignore_ascii_case("married") {
        if income < 60000 {
            0.2
        } else {
            0.25
        }
    } else if status.eq_ignore_ascii_case("single") {
        if income < 40000 {
            0.3
        } else {
            0.35
        }
    } else {
        return Err("invalid status");
    };

    if state == 'o' || state == 'O' {
        rate -= 0.03;
    } else if state != 'i' && state != 'I' {
        return Err("invalid state");
    }

    return Ok(rate * income as f64);
}
/// finds tax from given income and statuses
/// 
/// # Arguments
/// * `income` - the income to find tax for
/// * `status` - "married" or "single" (case insensitive)
/// * `state` - "i" for in state, "o" for out of state (case insensitive)
/// 
/// # Returns
/// the tax amount or an error message
finds tax from given income and statuses
finds tax from given income and statuses
fn compute_tax(income: i32, status: &str, state: char) -> Result<f64, &str> {
    let mut rate = if status.eq_ignore_ascii_case("married") {
        if income < 60000 {
            0.2
        } else {
            0.25
        }
    } else if status.eq_ignore_ascii_case("single") {
        if income < 40000 {
            0.3
        } else {
            0.35
        }
    } else {
        return Err("invalid status");
    };
    if state == 'o' || state == 'O' {
        rate -= 0.03;
    } else if state != 'i' && state != 'I' {
        return Err("invalid state");
    }
    return Ok(rate * income as f64);
}
fn compute_tax ( income : i32 , status : & str , state : char ) -> Result < f64 , & str > { let mut rate = if status . eq_ignore_ascii_case ( " " ) { if income < 60000 { 0.2 } else { 0.25 } } else if status . eq_ignore_ascii_case ( " " ) { if income < 40000 { 0.3 } else { 0.35 } } else { return Err ( " " ) ; } ; if state == 'o' || state == 'O' { rate -= 0.03 ; } else if state != 'i' && state != 'I' { return Err ( " " ) ; } return Ok ( rate * income as f64 ) ; }
finds tax from given income and statuses
finds tax from given income and statuses
income
i32
status
&str
state
char
the tax amount or an error message
the tax amount or an error message
income
i32
status
&str
state
char