fn net_salary(salary: f64) -> f64 { if salary < 200_000.0 { salary - 0.13 * salary } else if salary < 416_700.0 { let step1_part = 200_000.0 - 200_000.0 * 0.13; let step2_part = (salary - 200_000.0) - (salary - 200_000.0) * 0.15; step1_part + step2_part } else if salary < 1_670_000.0 { let step1_part = 200_000.0 - 200_000.0 * 0.13; let step2_part = (416_700.0 - 200_000.0) - (416_700.0 - 200_000.0) * 0.15; let step3_part = (salary - 416_700.0) - (salary - 416_700.0) * 0.18; step1_part + step2_part + step3_part } else if salary < 4_170_000.0 { let step1_part = 200_000.0 - 200_000.0 * 0.13; let step2_part = (416_700.0 - 200_000.0) - (416_700.0 - 200_000.0) * 0.15; let step3_part = (1_670_000.0 - 416_700.0) - (1_670_000.0 - 416_700.0) * 0.18; let step4_part = (salary - 1_670_000.0) - (salary - 1_670_000.0) * 0.20; step1_part + step2_part + step3_part + step4_part } else { let step1_part = 200_000.0 - 200_000.0 * 0.13; let step2_part = (416_700.0 - 200_000.0) - (416_700.0 - 200_000.0) * 0.15; let step3_part = (1_670_000.0 - 416_700.0) - (1_670_000.0 - 416_700.0) * 0.18; let step4_part = (4_170_000.0 - 1_670_000.0) - (4_170_000.0 - 1_670_000.0) * 0.20; let step5_part = (salary - 4_170_000.0) - (salary - 4_170_000.0) * 0.22; step1_part + step2_part + step3_part + step4_part + step5_part } } fn gross_salary(net_salary: f64) -> f64 { if net_salary <= 200_000.0 * (1.0 - 0.13) { net_salary / (1.0 - 0.13) } else if net_salary <= (200_000.0 * (1.0 - 0.13)) + (216_700.0 * (1.0 - 0.15)) { let step1_net = 200_000.0 * (1.0 - 0.13); let step2_net = net_salary - step1_net; 200_000.0 + step2_net / (1.0 - 0.15) } else if net_salary <= (200_000.0 * (1.0 - 0.13)) + (216_700.0 * (1.0 - 0.15)) + (1_253_300.0 * (1.0 - 0.18)) { let step1_net = 200_000.0 * (1.0 - 0.13); let step2_net = (416_700.0 - 200_000.0) * (1.0 - 0.15); let step3_net = net_salary - step1_net - step2_net; 416_700.0 + step3_net / (1.0 - 0.18) } else if net_salary <= (200_000.0 * (1.0 - 0.13)) + (216_700.0 * (1.0 - 0.15)) + (1_253_300.0 * (1.0 - 0.18)) + (2_500_000.0 * (1.0 - 0.20)) { let step1_net = 200_000.0 * (1.0 - 0.13); let step2_net = (416_700.0 - 200_000.0) * (1.0 - 0.15); let step3_net = (1_670_000.0 - 416_700.0) * (1.0 - 0.18); let step4_net = net_salary - step1_net - step2_net - step3_net; 1_670_000.0 + step4_net / (1.0 - 0.20) } else { let step1_net = 200_000.0 * (1.0 - 0.13); let step2_net = (416_700.0 - 200_000.0) * (1.0 - 0.15); let step3_net = (1_670_000.0 - 416_700.0) * (1.0 - 0.18); let step4_net = (4_170_000.0 - 1_670_000.0) * (1.0 - 0.20); let step5_net = net_salary - step1_net - step2_net - step3_net - step4_net; 4_170_000.0 + step5_net / (1.0 - 0.22) } }