compute tax.
Please help me out on my tax rate calculation. Really confusing.
Create a class TaxReturn with data elds suitable for holding a taxnumber, first name, family name, annual income, current address, and residency status along with the tax rates:
For Residents
Income Tax Rate
0 - $6,000 Nil
$6,001 - $37,000 15c for each $1 over $6,000
$37,001 - $80,000 $4,650 plus 30c for each $1 over $37,000
$80,001 - $180,000 $17,550 plus 37c for each $1 over $80,000
$180,001 and over $54,550 plus 45c for each $1 over $180,0001
For Non Residents
Income Tax Rate
0 - $35,000 29c for each $1
$35,001 - $80,000 $10,150 plus 30c for each $1 over $35,000
$80,001 - $180,000 $23,650 plus 38c for each $1 over $80,000
$180,001 and over $61,650 plus 45c for each $1 over $180,000
Assume that the tax data is not subject to change.
Include a function which displays these tables.
Include a default constructor and a constructor for which all non-tax-table elds must be specied.
Include a function computeTax, which determines the tax owed.
Include a function display(ostream& o) to display all the information associated with a taxpayer,
including his tax owed.
#include<iostream>
#include<string>
using namespace std;
class Address
{
private:
int postCode;
string country;
public:
Address(); //accessor function
void setPostCode(int);//two mutator function
void setCountry(string);
void displayAddress(); //display function use on taxreturn
};
Address::Address()
{
postCode=2555;
country = "europe";
}
void Address::setCountry(string Country)
{
country = Country;
}
void Address::setPostCode(int pCode)
{
postCode = pCode;
}
void Address::displayAddress()
{
cout<<"Postcode is: "<<postCode<<" and Country is: "<<country<<endl;
}
class TaxReturn
{
private:
int taxFileNumber;
string FirstName;
string FamilyName;
int AnnualIncome;
bool ResidencyStatus;
public:
TaxReturn(); //Include a default constructor and a constructor for which all non-tax-table elds must be speci.
void setTaxReturn(int, string, string, int, bool);
void ComputeTax();
void DisplayTable();//Include a function which displays these tables.
};
TaxReturn::TaxReturn()
{
taxFileNumber = 0;
FirstName = "james";
FamilyName = "cooper";
AnnualIncome = 6008;
ResidencyStatus = true;
}
void TaxReturn::setTaxReturn(int taxFile, string firstName, string famName, int AnnualInc, bool status)
{
taxFileNumber = taxFile;
FirstName = firstName;
FamilyName = famName;
AnnualIncome = AnnualInc;
ResidencyStatus = status;
}
void TaxReturn::ComputeTax()
{
double TaxRate;
if(ResidencyStatus = true)
{
cout<<"Residence"<<endl;
cout<<AnnualIncome<<endl;
if(AnnualIncome < 6000 && AnnualIncome > 0)
{
cout<<"Tax Rate is Nil"<<endl;
}
else if(AnnualIncome < 37000 && AnnualIncome > 6001)
{
cout<<"15c for each $1 over $6,000"<<endl;
TaxRate = (AnnualIncome - 6000) * 0.15;
}
else if(AnnualIncome < 80000 && AnnualIncome > 37001)
{
cout<<"$4,650 plus 30c for each $1 over $37,000"<<endl;
}
else if(AnnualIncome < 180000 && AnnualIncome > 80001)
{
cout<<"$17,550 plus 37c for each $1 over $80,000"<<endl;
}
else if(AnnualIncome > 180001)
{
cout<<"$54,550 plus 45c for each $1 over $180,000"<<endl;
}
}
if(ResidencyStatus = false)
{
cout<<"Non-Residence"<<endl;
}
if(AnnualIncome < 35000 && AnnualIncome > 0)
{
cout<<"29c for each $1"<<endl;
}
else if(AnnualIncome < 80000 && AnnualIncome > 35001)
{
cout<<"$10,150 plus 30c for each $1 over $35,000"<<endl;
}
else if(AnnualIncome < 180000 && AnnualIncome > 80001)
{
cout<<"$23,650 plus 38c for each $1 over $80,000"<<endl;
}
else if(AnnualIncome > 180001)
{
cout<<"$61,650 plus 45c for each $1 over $180,000"<<endl;
}
}
void TaxReturn:isplayTable()
{
Address aAddress;
aAddress.displayAddress();
cout<<"for residents\n"<<endl;
cout<<"Income Tax Rate\n"<<endl;
cout<<"0 { $6,000 Nil"<<endl;
cout<<"$6,001 { $37,000 15c for each $1 over $6,000"<<endl;
cout<<"$37,001 { $80,000 $4,650 plus 30c for each $1 over $37,000"<<endl;
cout<<"$80,001 { $180,000 $17,550 plus 37c for each $1 over $80,000"<<endl;
cout<<"$180,001 and over $54,550 plus 45c for each $1 over $180,000"<<endl;
cout<<"\n\nfor non-residents\n"<<endl;
cout<<"Income Tax Rate\n"<<endl;
cout<<"0 { $35,000 29c for each $1"<<endl;
cout<<"$35,001 { $80,000 $10,150 plus 30c for each $1 over $35,000"<<endl;
cout<<"$80,001 { $180,000 $23,650 plus 38c for each $1 over $80,000"<<endl;
cout<<"$180,001 and over $61,650 plus 45c for each $1 over $180,000\n\n"<<endl;
cout<<"Taxfile Number: "<<taxFileNumber<<endl;
cout<<"First Name: "<<FirstName<<endl;
cout<<"Family Name: "<<FamilyName<<endl;
cout<<"Annual Income: "<<AnnualIncome<<endl;
cout<<"Residency Status: "<<ResidencyStatus<<endl;
}
int main()
{
TaxReturn aTaxreturn;
aTaxreturn.DisplayTable();
aTaxreturn.ComputeTax();
}