#include<iostream>
#include<iomanip>
using namespace std;
void getData (char& maritalStatus, double& grossIncome, double& pensionAmount,
int& children, int& numPeople, double& standardExemption, double& persExemption);
double taxAmount(int numPerson, double grossIncome, double pensionAmount,
double persExemption, double standardExemption, double& totalTax);
int main()
{
char maritalStatus;
int children, numPerson;
double taxableIncome, totalTax, grossIncome, pensionAmount;
double standardExemption, persExemption, salary;
totalTax = taxAmount(numPerson, salary, pensionAmount, persExemption,
standardExemption, totalTax);
cout<<fixed << showpoint<<setprecision(2);
cout<<"Your tax for the year is: $"<< totalTax <<endl;
system("pause");
return 0;
}
void getData (char& maritalStatus, double& grossIncome, double& pensionAmount,
int& children, int& numPerson, double& standardExemption, double& persExemption)
{
double taxableIncome;
double pension;
cout << "Enter marital status: m or M (married), s or S (single: ";
cin >> maritalStatus;
cout << endl;
while(maritalStatus == 'm' || maritalStatus == 'M')
{
cout<< "Enter number of children under the age of 14: ";
cin >> children;
cout << endl;
numPerson = 2 + children;
standardExemption = 7000;
break;
}
while (maritalStatus =='s'||maritalStatus == 'S')
{
numPerson =1;
standardExemption= 4000;
break;
}
cout << "Enter gross Salary for the year: ";
cin >> grossIncome;
cout<<endl;
cout << "Enter percentage of salary contributed to pension(0-6 percent): ";
cin >> pension;
cout << endl;
pensionAmount = (pension/100)*grossIncome;
persExemption= numPerson * 1500;
taxableIncome= grossIncome-(pensionAmount + standardExemption + persExemption);
}
double taxAmount(int numPerson, double grossIncome, double pensionAmount,
double persExemption,double standardExemption,double& totalTax)
{
double taxableIncome, marginalIncome, marginTax, pension;
int tax;
double baseTax;
char maritalStatus;
int children;
double salary;
getData (maritalStatus, grossIncome, pensionAmount, children, numPerson,
standardExemption, persExemption);
if (taxableIncome <= 15000)
{
marginTax =.15 * taxableIncome;
totalTax = marginTax;
}
else if (taxableIncome >= 15001 || taxableIncome <= 40000)
{
marginalIncome = taxableIncome - 15000;
marginTax = .25 * taxableIncome;
baseTax = 2250;
totalTax = baseTax + marginTax;
}
else if (taxableIncome > 40000)
{
marginalIncome = taxableIncome - 40000;
marginTax = .35 * taxableIncome;
baseTax = 8460;
totalTax = baseTax + marginTax;
}
return totalTax;
}
Help with program errorC++ Program help with error
Page 1 of 1
2 Replies - 522 Views - Last Post: 30 July 2010 - 10:15 PM
#1
Help with program error
Posted 30 July 2010 - 07:32 PM
I am writing a program that will calculate federal tax for the year. I am running into a problem with getting the yearly tax to display. For some reason it is coming up as 0.00. I am not sure which function is causing the error. Here is the code and thanks in advance for the help.
Replies To: Help with program error
#2
Re: Help with program error
Posted 30 July 2010 - 08:53 PM
The value taxableincome is not returned from getData(), the default value is taxableincome=0, so totalTax is 0.
It looks like getData() would be better called from main().
It looks like getData() would be better called from main().
#3
Re: Help with program error
Posted 30 July 2010 - 10:15 PM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|