Must use codeblocks C An IRS agent is checking taxpayers ret
Solution
#include <iostream>
 #include <fstream>
 using namespace std;
    const int size=100;
   
     //read tax data from file and save into parallel arrauys
 int readFromFile(int taxid[size],double earnings[size],double tax[size])
 {
     int n=0;
     int tmp;
      ifstream myfile (\"earnings.txt\");
    if (myfile.is_open())
    {
        while(myfile>>tmp)
        {
            n++;
            taxid[n]=tmp;
            myfile>>earnings[n];
            myfile>>tax[n];
        }
        myfile.close();
     }
    else
    cout << \"Unable to open file\";
    return n;
 }
//calculate tax based on conditions provided
 void calTax(int n,int taxid[],double earnings[],double tax[],double refund[],double penalty[])
 {
     cout<<\"\ ******Calculating tax*********\ \";
     //loop though each tax payer
     for(int i=0;i<=n;i++)
     {
         //display the detils ofe ach tx payer
             cout<<\"\ ID: \"<<taxid[i];
             cout<<\"\ Earnings: \"<<earnings[i];
             cout<<\"\ Tax Paid: \"<<tax[i];
             //if earnings aren\'t between 30K and 40K,just exit
         if(earnings[i]>30000 && earnings[i]<=40000)
         {
             cout<<\"\ You are currently outside the tax cal bracket. Hence,no tax ia calauclated.\";
         }
         //else actual tax calculation comes into picture
         else
         {
             //calculate taxtobe paid based on income and check if refund/penalty has to be initiated
             double taxToBePaid=earnings[i]*0.205;
             //if he has paid less tax
             if(tax[i]<taxToBePaid)
             {
                 //caculate tax due
                 double taxDue=taxToBePaid-tax[i];
                 if(taxDue>1300)
                 {
                     penalty[i]+=0.02*(taxDue-1300);
                 }
                 penalty[i]+=taxDue*.04;
                 tax[i]+=penalty[i];
                 cout<<\"\ Penalty of \"<<penalty[i]<<\" has to be paid. You new tax now is \"<<tax[i];
             }
             //else calculate refund amt
             else if(tax[i]>taxToBePaid)
             {
                 refund[i]=tax[i]-taxToBePaid;
                 cout<<\"\ Refund of \"<<refund[i] <<\"will be initiated\";
             }
         }
     }
         cout<<\"\ ******Calculating tax DONE*********\";
 }
//get count of tax payers
 int getTaxPayerinRange(int n,double penalty[])
 {
     int count=0;
     for(int i=0;i<=n;i++)
     {
         if(penalty[i]==0)
         count++;
     }
     return count;
 }
//get count of tax payers who has refund
 int getTaxPayerRefund(int n,double refund[])
 {
     int count=0;
     for(int i=0;i<=n;i++)
     {
         if(refund[i]>0)
         count++;
     }
     return count;
 }
//get amt of refund amount
 double getRefundAmt(int n,double refund[])
 {
     double amt=0;
     for(int i=0;i<=n;i++)
     {
         if(refund[i]>0)
         amt+=refund[i];
     }
     return amt;
 }
//get count of tax payers who pay penalty
 int getTaxPayerPenalty(int n,double penalty[])
 {
     int count=0;
     for(int i=0;i<=n;i++)
     {
         if(penalty[i]>0)
         count++;
     }
     return count;
 }
//get penalty amount
 double getPenaltyAmt(int n,double penalty[])
 {
     double amt=0;
     for(int i=0;i<=n;i++)
     {
         if(penalty[i]>0)
         amt+=penalty[i];
     }
     return amt;
 }
//get tax amt paid
 double getTaxAmt(int n,double tax[])
 {
     double amt=0;
     for(int i=0;i<=n;i++)
     {
         if(tax[i]>0)
         amt+=tax[i];
     }
     return amt;
 }
//takes size of array and value and then computes average
 double computeAvg(int n,double value)
 {
     return value/n;
 }
//display the report
 void print(int n,double earnings[],double tax[],double refund[],double penalty[])
 {
     cout<<\"\ The total number of records in the data file: \"<<n;
     cout<<\"\ The total number of taxpayer’s checked in range: \"<<getTaxPayerinRange(n,penalty);
     cout<<\"\ The total number of taxpayer’s receiving refunds: \"<<getTaxPayerRefund(n,refund);
     cout<<\"\ The total dollar amount refunded \"<<getRefundAmt(n,refund);
     cout<<\"\ The total number of taxpayer’s that owe taxes \"<<getTaxPayerPenalty(n,penalty);
     cout<<\"\ The total dollar amount of taxes due \"<<getTaxAmt(n,tax);
     cout<<\"\ The total dollar amount of penalties due \"<<getPenaltyAmt(n,penalty);
     cout<<\"\ The average dollar amount refunded \"<<computeAvg(getTaxPayerRefund(n,refund),getRefundAmt(n,refund));
      cout<<\"\ The average dollar amount of taxes due \"<<computeAvg(getTaxPayerinRange(n,penalty),getTaxAmt(n,tax));
      cout<<\"\ The average dollar amount of the penalties due \"<<computeAvg(getTaxPayerPenalty(n,penalty),getPenaltyAmt(n,penalty));
  }
//main function
 int main()
 {
     //declare variables needed
     int n=-1;
     int taxid[size];
     double earnings[size];
     double tax[size];
     double refund[size];
     double penalty[size];
   
     //call required funcitons
     n=readFromFile(taxid,earnings,tax);
     calTax(n,taxid,earnings,tax,refund,penalty);
     print(n,earnings,tax,refund,penalty);
    return 0;
 }





