The IRS uses the following table Using ifelse if statements


The IRS uses the following table. Using if-else if statements determine the tax due for the income amounts in a variable-sized array earned income. Use the income array shown below to test your code. Income = [5000, 10000, 15000, 22000, 30000, 38000, 50000] Output should look like the following: The tax due on $5000 is: $500.00 The tax due on $10000 is: $1000.00 The tax due on $15000 is: $2000.00 The tax due on $22000 is: $3600.00 The tax due on $30000 is: $600.00 The tax due on $38000 is: $8400.00

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;
}

 The IRS uses the following table. Using if-else if statements determine the tax due for the income amounts in a variable-sized array earned income. Use the inc

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site