Hello, can anybody help me please?
I am new to C++. I need help with assignment that calculate income tax. thank you.
instruction:
*******
1.Set up a project called CTax.
2.Add to your project a class called GRTax.
3.The member variables for this class are: float mTaxableIncome, float mTaxRate, and RateType mRate which in an enum like:
enum RateType {LiveInWorkIn, LiveOutWorkOut, LiveOutWorkIn, LiveInWorkOut};
4.The member functions are: SetRate(RateType), SetTaxableIncome(float), and float GetTaxAmount(void).
5. It should have an overloaded constructor - one that passes no values, the other: CGRTax(RateType, float)
In the function, SetRate(RateType aRate), you need to set the tax rate (mRate)for the RateType being passed in. But what is the rate? For LiveInWorkIn - 1.6%, LiveOutWorkOut - 0%, LiveOutWorkIn - 0.6%, and LiveInWorkOut - 0.6%. So in this function, set up a switch/case statement that set mTaxRate depending on what is sent the function.
Here is what I got so far:
// CityTax.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include "GRTax.h"
using std::cout;
using std::endl;
using std::fixed;
class GRTax
{
public:
GRTax(void);
~GRTax(void);
float mTaxableIncome;
float mTaxRate;
RateType mRate;
void SetRate(RateType inrate);
void SetTaxableIncome(float);
float GetTaxAmount(void);
};
GRTax::GRTax(RateType T, float mm)
{
}
GRTax::GRTax(0)
{
}
int _tmain(int argc, _TCHAR* argv[])
{
GRTax MyGRTax;
MyGRTax.SetRate(LiveInWorkIn);
MyGRTax.SetTaxableIncome(44824.32f);
cout.precision( 2 );
cout << fixed << MyGRTax.GetTaxAmount() << endl;
GRTax MyOverLoadedGRTax(LiveInWorkOut,35694.53f); //test the overloaded function
cout << MyOverLoadedGRTax.GetTaxAmount() << endl << endl;
cout << "Press any key to continue" << endl;
_getch();
return 0;
}
void GRTax::SetRate(RateType inRate)//funtion
{
inRate = mRate;
switch(mRate)
{
case LiveInWorkIn:
mTaxRate = 1.6;
break;
case LiveOutWorkOut:
mTaxRate = 0;
break;
case LiveOutWorkIn:
mTaxRate = 0.6;
break;
case LiveInWorkOut:
mTaxRate = 0.6;
break;
default;
}
}
void GRTax::SetTaxableIncome(float)
{
}
float GRTax::GetTaxAmount(void)
{
return 0;
}