/*15% on the first $46,605 of taxable income, + 20.5% on the next $46,603 of taxable income (on the portion of taxable income over 46,605 up to $93,208), + 26% on the next $51,281 of taxable income (on the portion of taxable income over $93,208 up to $144,489), + 29% on the next $61,353 of taxable income (on the portion of taxable income over 144,489 up to $205,842), + 33% of taxable income over $205,842.
The output I am getting is:
Enter your total taxable income: 60000
Enter your total taxable income: 60000
Your federal income tax is: 9736.72 Program ended with exit code: 0 */
include
using namespace std;
float usersTax(){
float income;
cout <<"Enter your total taxable income: " <<flush;
cin >> income;
cout << endl;
float tax1;
float tax2;
float tax3;
float tax4;
float tax5;
float taxTotal;
if(income <= 46605){
taxTotal = income * 0.15;
}else if(income <= 93208){
tax1 = 46605 * 0.15;
tax2 = (income - 46605) * (0.205);
taxTotal = tax1 + tax2;
}else if(income <= 144489){
tax1 = 46605 * 0.15;
tax2 = 46603 * 0.205;
tax3 = (income - 93208) * (0.26);
taxTotal = tax1 + tax2 + tax3;
}else if(income <= 205842){
tax1 = 46605 * 0.15;
tax2 = 46603 * 0.205;
tax3 = 51281 * 0.26;
tax4 = (income - 144489) * (0.29);
taxTotal = tax1 + tax2 + tax3 +tax4;
}else{
tax1 = 46605 * 0.15;
tax2 = 46603 * 0.205;
tax3 = 51281 * 0.26;
tax4 = 144489 * 0.29;
tax5 = (income - 205842) * (0.33);
taxTotal = tax1 + tax2 + tax3 +tax4 + tax5;
}
return taxTotal;
}
int main() {
usersTax();
float finalTax = usersTax();
cout << "Your federal income tax is: " << finalTax << endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire