Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is taxdata.txt. this is taxedue.txt please, read the question carefully...

ID: 3845082 • Letter: T

Question

this is taxdata.txt.

this is taxedue.txt

please, read the question carefully...

thank you in advance.

In this project, you will use your programming skills to write a program that does the following 1. Reads the contents of a file called "taxdata.txt" 2. Create a class called Taxpayer tostore and keep track of each individual taxpayer 3. Store the data in a single list of Taxpayers 4. Write to a file called "taxesdue.txt" that contains each Taxpayer's name, social security number, and the remaining amount they owe (rounded to the nearest cent). The file should beformatted in organized columns and the entries should be sorted by the remaining tax owed. In order to do this assignment, you must create a user-defined class called Taxpayer. The class definition and member function definitions should be contained in a single file called Taxpayer h. IMPORTANT: for this assignment, you are turning in two files: the class definition Taxpayer.h, as well as hw6.cpp, the source file that creates your program. You do NOTturn in any text files! We will test your programonour own version of "taxdata.txt"

Explanation / Answer

This is Main.cpp

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <fstream>
#include "TaxPayer.h"
using namespace std;

bool compTaxPayers(TaxPayer *t1, TaxPayer *t2)
{
return (t1->Gettaxes_owed()<t2->Gettaxes_owed());
}

int main()
{
freopen("taxdata.txt","r",stdin);
freopen("taxdue.txt","w",stdout);
vector<TaxPayer *> taxPayerList;
int _ssn,n=0;
char lnTemp[10000], fnTemp[10000];
char status;
double income, taxes;
while(scanf("%d",&_ssn)!=EOF)
{
scanf("%s",lnTemp);
scanf("%s",fnTemp);
string ln(lnTemp);
string fn(fnTemp);
scanf("%c",&status);
scanf("%c",&status);
bool st = (status=='m');
scanf("%lf",&income);
scanf("%lf",&taxes);
TaxPayer * temp = new TaxPayer(_ssn,ln,fn,st,income,taxes);
temp->compute_owed_taxes();
taxPayerList.push_back(temp);
fflush(stdin);
n++;
}
sort(taxPayerList.begin(),taxPayerList.end(),compTaxPayers);
printf("SSN Last Name First Name Tax Due ");
for(int i=0;i<n;i++)
{
cout<<taxPayerList[i]->Getssn()<<" "<<taxPayerList[i]->Getlast_name()<<" "<<taxPayerList[i]->Getfirst_name()<<" ";
printf("%.2lf ",taxPayerList[i]->Gettaxes_owed());
}
return 0;
}

And here is the TaxPayer.h file

#ifndef TAXPAYER_H
#define TAXPAYER_H
#include<string>
using namespace std;
class TaxPayer
{
public:
TaxPayer();
TaxPayer(int _ssn, string _last_name, string _first_name, bool _filing_status, double _gross_income, double _taxes_paid )
{
ssn = _ssn;
last_name = _last_name;
first_name = _first_name;
filing_status = _filing_status;
gross_income = _gross_income;
taxes_paid = _taxes_paid;
}
virtual ~TaxPayer();

int Getssn() { return ssn; }
void Setssn(int val) { ssn = val; }
string Getlast_name() { return last_name; }
void Setlast_name(string val) { last_name = val; }
string Getfirst_name() { return first_name; }
void Setfirst_name(string val) { first_name = val; }
bool Getfiling_status() { return filing_status; }
void Setfiling_status(bool val) { filing_status = val; }
double Getgross_income() { return gross_income; }
void Setgross_income(double val) { gross_income = val; }
double Gettaxes_paid() { return taxes_paid; }
void Settaxes_paid(double val) { taxes_paid = val; }
double Gettaxes_owed() { return taxes_owed; }
void Settaxes_owed(double val) { taxes_owed = val; }

void compute_owed_taxes()
{
double taxes_net_owed;
if(!(this->filing_status))
{
if(this->gross_income<=37650)
taxes_net_owed = this->gross_income * 0.15;
else if(this->gross_income<=91150)
taxes_net_owed = this->gross_income * 0.25;
else
taxes_net_owed = this->gross_income * 0.28;
}
else
{
if(this->gross_income<=75300)
taxes_net_owed = this->gross_income * 0.15;
else if(this->gross_income<=151900)
taxes_net_owed = this->gross_income * 0.25;
else
taxes_net_owed = this->gross_income * 0.28;
}
this->taxes_owed = taxes_net_owed - this->taxes_paid;
}

bool operator<(TaxPayer const &t1)
{
if(this->taxes_owed<t1.taxes_owed)
return true;
else
return false;
}

protected:

private:
int ssn;
string last_name;
string first_name;
bool filing_status;
double gross_income;
double taxes_paid;
double taxes_owed;
};

#endif // TAXPAYER_H