/****************************************************************************** * This program computes employee and employer FICA and FUTA taxes. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ #undef NDEBUG #include "Utils.hpp" #include #include #include using namespace Utils; using namespace std; static double const SS_TAX_RATE = 0.062; static double const SS_LIMIT = 127200.0; static double const MEDICARE_TAX_RATE1 = 0.0145; static double const MEDICARE_TAX_RATE2 = 0.0235; static double const MEDICARE_BREAKPOINT = 200000.0; static double const FUTA_TAX_RATE = 0.06; static double const FUTA_BREAKPOINT = 7000.0; int main(int argc, char **argv) { if (argc != 3) { cout << fmt::format("Syntax: {0:s} annual_wages annual_tips", argv[0]) << endl; exit(1); } double const ANNUAL_WAGES = Utils::stodWithDefault(string(argv[1]), 0.0); double const ANNUAL_TIPS = Utils::stodWithDefault(string(argv[2]), 0.0); double const ANNUAL_EARNINGS = ANNUAL_WAGES + ANNUAL_TIPS; double ss_tax; if (ANNUAL_EARNINGS < SS_LIMIT) { ss_tax = ANNUAL_EARNINGS * SS_TAX_RATE; } else { ss_tax = SS_LIMIT * SS_TAX_RATE; } double medicare_tax; double employer_medicare_tax; if (ANNUAL_EARNINGS <= MEDICARE_BREAKPOINT) { medicare_tax = ANNUAL_EARNINGS * MEDICARE_TAX_RATE1; employer_medicare_tax = ANNUAL_EARNINGS * MEDICARE_TAX_RATE1; } else { medicare_tax = MEDICARE_BREAKPOINT * MEDICARE_TAX_RATE1 + (ANNUAL_EARNINGS - MEDICARE_BREAKPOINT) * MEDICARE_TAX_RATE2; employer_medicare_tax = ANNUAL_EARNINGS * MEDICARE_TAX_RATE1; } double futa_tax; if (ANNUAL_EARNINGS <= FUTA_BREAKPOINT) { futa_tax = ANNUAL_EARNINGS * FUTA_TAX_RATE; } else { futa_tax = FUTA_BREAKPOINT * FUTA_TAX_RATE; } double const NET_EARNINGS = ANNUAL_EARNINGS - ss_tax - medicare_tax; double const EMPLOYER_CONTRIBUTIONS = ANNUAL_EARNINGS + ss_tax + employer_medicare_tax + futa_tax; cout << fmt::format("Annual Earnings: ${0:.2f}", ANNUAL_EARNINGS) << endl; cout << fmt::format("Social Security Tax: ${0:.2f}", ss_tax) << endl; cout << fmt::format("Medicare Tax: ${0:.2f}", medicare_tax) << endl; cout << fmt::format("Employer Social Security Tax: ${0:.2f}", ss_tax) << endl; cout << fmt::format("Employer Medicare Tax: ${0:.2f}", employer_medicare_tax) << endl; cout << fmt::format("Federal Unemployment Tax: ${0:.2f}", futa_tax) << endl; cout << fmt::format("Net Earnings: ${0:.2f}", NET_EARNINGS) << endl; cout << fmt::format("Employer Contributions: ${0:.2f}", EMPLOYER_CONTRIBUTIONS) << endl; return 0; }