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
|
#include <iomanip>
#include <iostream>
//Tax calculation function
double cal_Tax(int age, int income);
int main()
{
int age[] = {24, 19, 47, 50, 35, 26};
int income[] = {40000, 20000, 100000, 35000, 75000, 28000};
int size = sizeof(age) / sizeof(int);
double* tax = new double[size];
for(int i=0; i<size; i++) {
tax[i] = cal_Tax(age[i], income[i]);
}
std::cout << "\nLastname(initial)" << "\tFNPF#" << "\tAGE" << "\tIncome" << "\tTax";
std::cout << "\n-----------------" << "\t-----" << "\t---" << "\t------" << "\t---\n";
int fnpfnbr[] = {12345, 12361, 34763, 11224, 54129, 10717};
char lastname_initial[] = {'F', 'B', 'H', 'H', 'R', 'B'};
for (int i=0; i<size; i++) {
std::cout << lastname_initial[i] << "\t\t\t" << fnpfnbr[i]
<< '\t' << age[i] << '\t' << income[i]
<< '\t' << tax[i] << '\n';
}
delete[] tax;
return 0;
}
double cal_Tax(int age, int income) //A for Age, I for Income (Parameters)
{
double incdoub = double(income);
if(age < 55) {
if(income <= 10000) {return 0;}
if(income <= 50000) {return incdoub * 10/100;}
if(income <= 100000) {return incdoub * 20/100;}
return incdoub * 30/100;
}
else if (55 < age && age < 80) {
if(income <= 20000) {return 0;}
if(income <= 70000) {return incdoub * 10/100;}
if(income <= 150000) {return incdoub * 20/100;}
return incdoub * 30/100;
}
return 0;
}
|