I am working on an assignment for my C++ course, and could really use some help with the following problem:
Instructions:
1. In this assignment we are going to write an object oriented program to calculate provincial tax, federal tax and net income. Your objective is to design a class called CTaxCalc with the following functionality.
1. The program should allow you to enter a SIN number, gross income and province code and display the Federal Tax Amount, Provincial Tax Amount and Net Income.
2. Federal Tax – if gross income > 55000 then the tax rate is .28 otherwise it’s .21.
3. Provincial Tax is calculated according to the following table, use an if statement in your class to determine the provincial tax.
Province Code Tax Rate
ON .19
BC .22
MB .11
NS .09
QC .13
SK .06
4. Your class must contain a default constructor and at least 1 overloaded constructor to initialize your variables.
5. Pay close attention as to which class member functions and variables should public or private.
6. You do not need a menu for this assignment; we are strictly focusing on class design.
7. Your class should contain the appropriate GetValue() methods to display private variables to the screen.
8. Instantiate at least 3 objects of type CTaxCalc and display the results to the screen.
Here is the code that I have. I know for a fact, then I am not using the class properly, and I am not sure exactly how I would implement a default constructor or an overloaded constructor. Any help would be greatly appreciated!!!
// lab4.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class CTaxCalc
{
public:
double PTaxAmount(double, double);
double FTaxAmount(double, double);
double NIncome(double, double, double);
void output(int, double, double, double);
};
int _tmain(int argc, _TCHAR* argv[])
{
//Variable Declarations
int sinNumber;
double provincialTaxRate;
double federalTaxRate;
double grossIncome;
double federalTaxAmount;
double provincialTaxAmount;
double netIncome;
string provinceCode;
//Input
cout << "Enter S.I.N. Number: ";
cin >> sinNumber;
cout << "Enter gross income: ";
cin >> grossIncome;
cout << "Enter Province code: ";
cin >> provinceCode;
if (provinceCode == "ON")
{
provincialTaxRate = 19;
}
else if (provinceCode == "BC")
{
provincialTaxRate = 22;
}
else if (provinceCode == "MB")
{
provincialTaxRate = 11;
}
else if (provinceCode == "NS")
{
provincialTaxRate = 9;
}
else if (provinceCode == "QC")
{
provincialTaxRate = 13;
}
else if (provinceCode == "SK")
{
provincialTaxRate = 6;
}
if (grossIncome <= 55000)
{
federalTaxRate = 28;
}
else
{
federalTaxRate = 21;
}
CTaxCalc Lab4;
provincialTaxAmount = Lab4.PTaxAmount(provincialTaxRate, grossIncome);
federalTaxAmount = Lab4.FTaxAmount(grossIncome, federalTaxRate);
netIncome = Lab4.NIncome(provincialTaxAmount, grossIncome, federalTaxAmount);
Lab4.output(sinNumber, federalTaxAmount, provincialTaxAmount, netIncome);
return 0;
}
//Calculation Functions
double CTaxCalc::PTaxAmount( double provincialTaxRate, double grossIncome)
{
//calculations
double provincialTaxAmount;
provincialTaxAmount = provincialTaxRate / 100 * grossIncome;
return provincialTaxAmount;
}
double CTaxCalc::FTaxAmount(double grossIncome, double federalTaxRate)
{
//calculations
double federalTaxAmount;
federalTaxAmount = federalTaxRate / 100 * grossIncome;
return federalTaxAmount;
}
double CTaxCalc::NIncome(double provincialTaxAmount, double grossIncome, double federalTaxAmount)
{
//calculations
double netIncome;
netIncome = grossIncome - provincialTaxAmount - federalTaxAmount;
return netIncome;
}
void CTaxCalc::output(int sinNumber, double federalTaxAmount, double provincialTaxAmount, double netIncome)
{
//output
cout << endl;
cout << "S.I.N. Number: " << sinNumber << endl;
cout << "Federal Tax Amount: $" << setprecision(2) << fixed << federalTaxAmount << endl;
cout << "Provincial Tax Amount: $" << setprecision(2) << fixed << provincialTaxAmount << endl;
cout << "Net Income: $" << setprecision(2) << fixed << netIncome << endl;
system ("pause");
}