#include double calcTax(double income); int main() { std::cout << "calcTax(90000.0) == " << calcTax(90000.0) << "\n"; std::cout << "calcTax(120000.0) == " << calcTax(120000.0) << "\n"; std::cout << "calcTax(750000.0) == " << calcTax(750000.0) << "\n"; std::cout << "calcTax(3500000.0) == " << calcTax(3500000.0) << "\n"; std::cout << "calcTax(9000000.0) == " << calcTax(9000000.0) << "\n"; return 0; } //-------------------------------------------------------------------------- // @description calculate the tax from the income // income rate // <= 100,000 0% // 100,000 < income <= 500,000 12% // 500,000 < income <= 1,000,000 15% // 1,000,000 < income <= 5,000,000 23% // > 5,000,000 28% // @param income the individual income // @return the tax // @contract calcTax : double -> double // @example calcTax(90000.0) == 0.0 // @example calcTax(120000.0) == 2400 // @example calcTax(750000.0) == 85500.0 // @example calcTax(3500000.0) == 698000.0 // @example calcTax(9000000.0) == 2163000.0 //-------------------------------------------------------------------------- double calcTax(double income) { if (income <= 100000.0) { return 0.0; } else if (income <= 500000.0) { return (income - 100000.0) * 0.12; } else if (income <= 1000000.0) { return (income - 500000.0) * 0.15 + 48000; } else if (income <= 5000000.0) { return (income - 1000000.0) * 0.23 + 123000.0; } else { return (income - 5000000.0) * 0.28 + 1043000.0; } }