The IRS uses the following table Using ifelse if statements
Solution
Since no programming language is choice is given, I am assuming it is C++
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int income[] = { 5000, 10000, 15000, 22000, 30000, 38000, 50000 };
int sizeofArray = sizeof(income)/sizeof(income[0]);
for(int i =0 ; i < sizeofArray; i++){
double taxIs = -1;
if(income[i] <= 10000){ taxIs = 0.1*income[i]; }
else if(income[i] <= 20000){ taxIs = 0.2*(income[i]-10000) + 1000; }
else if(income[i] <= 40000){ taxIs = 0.3*(income[i]-20000) + 3000; }
else{ taxIs = 0.5*(income[i]-40000) + 9000; }
cout << fixed << setprecision(2);
cout << \"The tax due on $5000 is: $\" << taxIs << endl;
}
return 0;
}
