« Back to profile of picodev

  • C++

    ousamam

    c++ tax

    22:08 Nov 13 2010 | Tags :
    						#include <stdio.h>
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

class CTaxCalc
{
public:
    int sinNumber;
    //constructor definition
    CTaxCalc(int sn, double gi, string pc)
    {
        cout << endl << "Constructor called.";
        //set values of data members
        sinNumber = sn;
        grossIncome = gi;
        provCode = pc;
    }
    //default constructor instantiation
    CTaxCalc()
    {
        cout << endl << "Default constructor called.";
    }
    //function to calculate provincial taxes
double ProvTaxFunction()
    {
        if(provCode == "ON")
        {
            provTaxRate = 0.19;
        }
        if(provCode == "BC")
        {
            provTaxRate = 0.22;
        }
        if(provCode == "MB")
        {
            provTaxRate = 0.11;
        }
        if(provCode == "NS")
        {
            provTaxRate = 0.09;
        }
        if(provCode == "QC")
        {
            provTaxRate = 0.13;
        }
        if(provCode == "SK")
        {
            provTaxRate = 0.06;
        }
        return grossIncome * provTaxRate;
    }

    //function to calculate federal taxes
    double FedTaxFunction()
    {
        if(grossIncome  > 55000)
        {
            fedTaxRate = 0.28;
        }
        else
        {
            fedTaxRate = 0.21;
        }

        return grossIncome * fedTaxRate;
    }
private:
    double grossIncome;
    string provCode;
    double fedTaxRate;
    double provTaxRate;
};

int main()
{
    //variables
    double netIncome = 0;
    int sn = 0;
    double gi = 0.0;
    string pc = "";
    //declare tax1

    cout << "Please enter your sin number" << endl;
    cin >> sn;
    cout << "Please enter your grossIncome" << endl;
    cin >> gi;
    cout << "Please enter your provCode" << endl;
    cin >> pc;
    CTaxCalc tax1(sn, gi, pc);
    cout << endl << "sin is " << tax1.sinNumber;
    cout << endl << "federal tax * grossIncome = " << tax1.FedTaxFunction();
    cout << endl << "prov tax = " << tax1.ProvTaxFunction();
    cout << endl;
    char c = cin.get();
    return 0;
}    			         
Add comment
To add a comment, please : Login or Sign up
    picodev
    alae
  • New visitor?

    On setCode, you can save your codes, functions and classes, you can also share them with your friends, and track your favorite developer

    Join the SetCode community
  • Your language here :