1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class TaxReturn
{
private:
int taxId;
string name;
double income;
int dependents;
double taxAmt;
void computeTax();
public:
TaxReturn (int = 0, string = "" , double = 0.0, int = 0);
void setAll (int, string, double, int);
void display();
};
TaxReturn :: TaxReturn (int TAXID, string NAME, double INCOME, int DEPENDENTS)
{
taxId = TAXID;
name = NAME;
income = INCOME;
dependents = DEPENDENTS;
}
void TaxReturn :: setAll (int TAXID, string NAME, double INCOME, int DEPENDENTS)
{
taxId = TAXID;
name = NAME;
income = INCOME;
dependents = DEPENDENTS;
computeTax();
}
void TaxReturn :: display()
{
cout << "\nID #" << taxId << "\t" << name << "," << endl;
cout << " " << dependents << " dependents" << endl;
cout << " " << "Income $" << income << "\tTax Owned $" << taxAmt << endl;
}
void TaxReturn :: computeTax()
{
if (income > 60000.00)
{
if (dependents > 4)
{
taxAmt = 0.20 * income;
}
else
{
taxAmt = 0.30 * income;
}
}
else if (income >= 40000 && income <= 60000)
{
if (dependents > 4)
{
taxAmt = 0.10 * income;
}
else
{
taxAmt = 0.20 * income;
}
}
else if (income >= 20000 && income < 40000)
{
if (dependents > 4)
{
taxAmt = 0.05 * income;
}
else
{
taxAmt = 0.10 * income;
}
}
else if (income < 20000) ;
{
taxAmt = 0;
}
}
int main()
{
TaxReturn a, b, c;
a.setAll (1, "John Smith", 60000.00, 5);
b.setAll (2, "Tan Ah Kow", 19000.00, 2);
c.setAll (3, "Sing Sum San", 40500.00, 1);
cout << "\nSummary" << endl;
a.display();
b.display();
c.display();
cin.ignore();
return 0;
}
|