#!/usr/bin/env python3; ############################################################################### # This program computes federal income tax. # # Copyright © 2020 Richard Lesh. All rights reserved. ############################################################################### import Utils import sys # Begin Main income = 0. status = "S" income_tax = 0. if (len(sys.argv) == 3) : income = Utils.stodWithDefault(sys.argv[1], 0) status = sys.argv[2] else : print("Syntax: {0:s} income S|M|H".format(sys.argv[0])) sys.exit(1) if (status == "H") : if (income <= 14100.) : income_tax += income * 0.10 else : income_tax += 14100. * 0.10 if (income <= 53700.) : income_tax += (income - 14100.) * 0.12 else : income_tax += (53700. - 14100.) * 0.12 if (income <= 85500.) : income_tax += (income - 53700.) * 0.22 else : income_tax += (85500. - 53700.) * 0.22 if (income <= 163300.) : income_tax += (income - 85500.) * 0.24 else : income_tax += (163300. - 85500.) * 0.24 if (income <= 207350.) : income_tax += (income - 163300.) * 0.32 else : income_tax += (207350. - 163300.) * 0.32 if (income <= 518400.) : income_tax += (income - 207350.) * 0.35 else : income_tax += (518400. - 207350.) * 0.35 if (income > 518400.) : income_tax += (income - 518400.) * 0.37 elif (status == "M") : if (income <= 19750.) : income_tax += income * 0.10 else : income_tax += 19750. * 0.10 if (income <= 80250.) : income_tax += (income - 19750.) * 0.12 else : income_tax += (80250. - 19750.) * 0.12 if (income <= 171050.) : income_tax += (income - 80250.) * 0.22 else : income_tax += (171050. - 80250.) * 0.22 if (income <= 326600.) : income_tax += (income - 171050.) * 0.24 else : income_tax += (326600. - 171050.) * 0.24 if (income <= 414700.) : income_tax += (income - 326600.) * 0.32 else : income_tax += (414700. - 326600.) * 0.32 if (income <= 622050.) : income_tax += (income - 414700.) * 0.35 else : income_tax += (622050. - 414700.) * 0.35 if (income > 622050.) : income_tax += (income - 622050.) * 0.37 else : if (income <= 9875.) : income_tax += income * 0.10 else : income_tax += 9875. * 0.10 if (income <= 40125.) : income_tax += (income - 9875.) * 0.12 else : income_tax += (40125. - 9875.) * 0.12 if (income <= 85525.) : income_tax += (income - 40125.) * 0.22 else : income_tax += (85525. - 40125.) * 0.22 if (income <= 163300.) : income_tax += (income - 85525.) * 0.24 else : income_tax += (163300. - 85525.) * 0.24 if (income <= 207350.) : income_tax += (income - 163300.) * 0.32 else : income_tax += (207350. - 163300.) * 0.32 if (income <= 518400.) : income_tax += (income - 207350.) * 0.35 else : income_tax += (518400. - 207350.) * 0.35 if (income > 518400.) : income_tax += (income - 518400.) * 0.37 print("Federal Income Tax: ${0:.2f}".format(income_tax))