i just started with C++ program so i know very little programming .
i have to make a program that calculates tax

the senerio is this
Federal:
15% on the first $43 561 of taxable income, +
22% on the next $43 562 of taxable income, (on the portion of taxable income over $43 561 to $87 123) +
26% on the next $47 931 of taxable income, (on the portion of taxable income over $87 123 to $135 054) +
29% of taxable income over $135 054

Provincial (Ontario):

5.05% on the first $39 723 of taxable income, +
9.15% on the next $39 725 of taxable income, (on the portion of taxable income over $39 723 up to $79 448) +
11.16% on the next $429552 of taxable income, (on the portion of taxable income over $79 448 up to $509 000) +
13.16% of taxable income over $ 509 000

Provincial (Alberta):
10% of taxable income

this is what i have so far:

#include <iostream>;
using namespace std;



int calculateFederalTaxes(int Income);
int calculateProvincialTaxes(int Income, int Province);
int calculateOntarioTaxes(int Income);
int calculateAlbertaTaxes(int Income);
int totalTaxes(int Income, int calculateFederalTaxes, int calculateProvincialTaxes);




void main()
{
    int Income;
    int Province;
    float FederalTaxes = calculateFederalTaxes(Income);
    float Provincial = calculateProvincialTaxes(Income, Province);
    int totalTaxes(int Income, int calculateFederalTaxes, int calculateProvincialTaxes);


    cout << "Welcome to the tax calculation system" << endl << endl;

    cout << "Select the province yo live in: "<< endl << endl;

int one;

    cout << "1 = Ontario" << endl;

int two;

    cout <<"2 = Alberta" << endl;

    cout << "what is your selection"<<endl <<endl;
    cin >> Province;

if (Province == 1){
    cout << "Ontario" << endl <<endl;
}
else if (Province == 2){
    cout << "Alberta" << endl <<endl;
}
else {
    cout <<"This is a wrong selection" << endl <<endl;
}   

    cout << "Please enter your income" << Income << endl <<endl;
    cin >> Income;  

//.federal tax

int calculateFederalTaxes(int Income);

    if (Income >= 0 || Income <= 43561){
         FederalTaxes = Income*0.15;
    }
    else if (Income >=43562 |Income <= 87123){
         FederalTaxes = Income*0.22;
    }

    else if (Income >=87123 |Income <= 135054){
         FederalTaxes = Income*0.26;
    }
    else if (Income >=135054){
         FederalTaxes = Income*0.29;

    cout << "The federal tax will be: " << FederalTaxes << endl << endl; 
    }

}

i am stuck after this , a little help would be appreciative.
please and thank you

Recommended Answers

All 3 Replies

The tax is a sliding scale, so what you have done needs to revised.
Eg. if your income was $75,000, tax would be calculated as such.
Total tax = $43,561 at 15% + (75,000 - 43,561) at 22% .
Base your algorithm on this.

Milton

Thank you, i changed my alogorithm but i have a question for the ProvincialTaxes how would i tell the program if they choose ontario then do this or if they choose alberta than do this, ?

The simplest way would be to create a method (function) to resovle the tax payable for each of the 2 Provinces. Pass the income(float value) as a parameter to the method and returning the tax payable (float value).

float calcTaxAlberta(float income)
{
    float taxPayable;
    .....
    return taxPayable;
}

float calcTaxOnterio(float income)
{
    float taxPayable;
    .....
    return taxPayable;
}

Use a "switch" or "if" statements to select the the tax calculation method.

Milton

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.