Tax Calcualtion Using Functions

Hi, I'm trying to edit a recently written program to use specific funtions: calcSingle(income), calcMarriedFilingJointly(), calcMarriedFilingSep(), calcHeadOfHousehold. I'm new to programming and am very lost when it comes to functions. I've posted my unchanged program below and maybe someone can point me in the right direction? Thanks!

#include <iostream> // Required for cout and cin
#include <cmath> // Required for calculations
#include <iomanip> // Required for setprecision

using namespace std;

//Declare Variables
double status;
double taxable;
double tax;

//Declare Constants
const int SINGLE10 = 8700;
const int SINGLE15 = 35350;
const int SINGLE25 = 85650;
const int SINGLE28 = 178650;
const int SINGLE33 = 388350;
const int JOINTLY10 = 17400;
const int JOINTLY15 = 70700;
const int JOINTLY25 = 142700;
const int JOINTLY28 = 217450;
const int JOINTLY33 = 388350;
const int SEPARATE10 = 8700;
const int SEPARATE15 = 35350;
const int SEPARATE25 = 71350;
const int SEPARATE28 = 108725;
const int SEPARATE33 = 194175;
const int HEAD10 = 12400;
const int HEAD15 = 47350;
const int HEAD25 = 122300;
const int HEAD28 = 198050;
const int HEAD33 = 388350;

int main ()
{
//Decimal Point Precision
cout.setf(ios_base::fixed,ios_base::floatfield);
cout.precision(2);

//Character Based While Loop
char answer = 'y';
while (answer == 'y')
{
//User Input for Status
cout<<"Please enter your filing status"<<endl;
cout<<"Enter 0 for single filers,"<<endl;
cout<<" 1 for married filing jointly,"<<endl;
cout<<" 2 for married filing separately, or"<<endl;
cout<<" 3 for head of household."<<endl;
cout<<"Status: ";
cin>> status;
//User Input for Taxable Income
cout<<"Please enter your taxable income: ";
cin>> taxable;
//User Input: Single
if (status == 0)
{
if (taxable <= SINGLE10)
{
tax=taxable*.1;
}
if (taxable > SINGLE10 && taxable <=SINGLE15)
{
tax = (SINGLE10*.1)+(taxable-SINGLE10)*.15;
}
if (taxable > SINGLE15 && taxable <=SINGLE25)
{
tax = (SINGLE10*.1)+(SINGLE15-SINGLE10)*.15+(taxable-SINGLE15)*.25;
}
if (taxable > SINGLE25 && taxable <= SINGLE28)
{
tax = (SINGLE10*.1)+(SINGLE15-SINGLE10)*.15+(SINGLE25-SINGLE15)*.25+(taxable-SINGLE25)*.28;
}
if (taxable > SINGLE28 && taxable <= SINGLE33)
{
tax = (SINGLE10*.1)+(SINGLE15-SINGLE10)*.15+(SINGLE25-SINGLE15)*.25+(SINGLE28-SINGLE25)*.28+(taxable-SINGLE28)*.33;
}
if (taxable > SINGLE33)
{
tax = (SINGLE10*.1)+(SINGLE15-SINGLE10)*.15+(SINGLE25-SINGLE15)*.25+(SINGLE28-SINGLE25)*.28+(SINGLE33-SINGLE28)*.33+(taxable-SINGLE33)*.35;
}
cout<<"Tax is " << tax <<endl;
}

//User Input: Married, Filing Jointly
if (status == 1)
{
if (taxable <= JOINTLY10)
{
tax=taxable*.1;
}
if (taxable > JOINTLY10 && taxable <=JOINTLY15)
{
tax = (JOINTLY10*.1)+(taxable-JOINTLY10)*.15;
}
if (taxable > JOINTLY15 && taxable <=JOINTLY25)
{
tax = (JOINTLY10*.1)+(JOINTLY15-JOINTLY10)*.15+(taxable-JOINTLY15)*.25;
}
if (taxable > JOINTLY25 && taxable <= JOINTLY28)
{
tax = (JOINTLY10*.1)+(JOINTLY15-JOINTLY10)*.15+(JOINTLY25-JOINTLY15)*.25+(taxable-JOINTLY25)*.28;
}
if (taxable > JOINTLY28 && taxable <= JOINTLY33)
{
tax = (JOINTLY10*.1)+(JOINTLY15-JOINTLY10)*.15+(JOINTLY25-JOINTLY15)*.25+(JOINTLY28-JOINTLY25)*.28+(taxable-JOINTLY28)*.33;
}
if (taxable > JOINTLY33)
{
tax = (JOINTLY10*.1)+(JOINTLY15-JOINTLY10)*.15+(JOINTLY25-JOINTLY15)*.25+(JOINTLY28-JOINTLY25)*.28+(JOINTLY33-JOINTLY28)*.33+(taxable-JOINTLY33)*.35;
}
cout<<"Tax is " << tax <<endl;
}
//User Input: Married, Filing Separately
if (status == 2)
{
if (taxable <= SEPARATE10)
{
tax=taxable*.1;
}
if (taxable > SEPARATE10 && taxable <=SEPARATE15)
{
tax = (SEPARATE10*.1)+(taxable-SEPARATE10)*.15;
}
if (taxable > SEPARATE15 && taxable <=SEPARATE25)
{
tax = (SEPARATE10*.1)+(SEPARATE15-SEPARATE10)*.15+(taxable-SEPARATE15)*.25;
}
if (taxable > SEPARATE25 && taxable <= SEPARATE28)
{
tax = (SEPARATE10*.1)+(SEPARATE15-SEPARATE10)*.15+(SEPARATE25-SEPARATE15)*.25+(taxable-SEPARATE25)*.28;
}
if (taxable > SEPARATE28 && taxable <= SEPARATE33)
{
tax = (SEPARATE10*.1)+(SEPARATE15-SEPARATE10)*.15+(SEPARATE25-SEPARATE15)*.25+(SEPARATE28-SEPARATE25)*.28+(taxable-SEPARATE28)*.33;
}
if (taxable > SEPARATE33)
{
tax = (SEPARATE10*.1)+(SEPARATE15-SEPARATE10)*.15+(SEPARATE25-SEPARATE15)*.25+(SEPARATE28-SEPARATE25)*.28+(SEPARATE33-SEPARATE28)*.33+(taxable-SEPARATE33)*.35;
}
cout<<"Tax is " << tax <<endl;
}

//User Input: Head of Household
if (status == 3)
{
if (taxable <= HEAD10)
{
tax=taxable*.1;
}
if (taxable > HEAD10 && taxable <= HEAD15)
{
tax = (HEAD10*.1)+(taxable-HEAD10)*.15;
}
if (taxable > HEAD15 && taxable <=HEAD25)
{
tax = (HEAD10*.1)+(HEAD15-HEAD10)*.15+(taxable-HEAD15)*.25;
}
if (taxable > HEAD25 && taxable <= HEAD28)
{
tax = (HEAD10*.1)+(HEAD15-HEAD10)*.15+(HEAD25-HEAD15)*.25+(taxable-HEAD25)*.28;
}
if (taxable > HEAD28 && taxable <= HEAD33)
{
tax = (HEAD10*.1)+(HEAD15-HEAD10)*.15+(HEAD25-HEAD15)*.25+(HEAD28-HEAD25)*.28+(taxable-HEAD28)*.33;
}
if (taxable > HEAD33)
{
tax = (HEAD10*.1)+(HEAD15-HEAD10)*.15+(HEAD25-HEAD15)*.25+(HEAD28-HEAD25)*.28+(HEAD33-HEAD28)*.33+(taxable-HEAD33)*.35;
}
cout<<"Tax is " << tax <<endl;
}

//User Input: Invalid
if (status > 3)
{
cout<<"This is not a valid status."<<endl;
}
cout<<"Calculate another Tax? <enter 'y' for yes and 'n' for no> ";
cin>>answer;
}
return(0);
}
Topic archived. No new replies allowed.