Hello, can anybody help me please?
I am new to C++. I need help with assignment that calculate income tax. thank you.

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
	float mTaxableIncome;
	float mTaxRate;
	RateType mRate;
	void SetRate(RateType inrate);
	void SetTaxableIncome(float);
	float GetTaxAmount(void);

GRTax::GRTax(RateType T, float mm)



int _tmain(int argc, _TCHAR* argv[])

	GRTax MyGRTax;
	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;

	return 0;

void GRTax::SetRate(RateType inRate)//funtion
	inRate = mRate;
	    case LiveInWorkIn:
		    mTaxRate = 1.6;
		case LiveOutWorkOut:
			mTaxRate = 0;
		case LiveOutWorkIn:
			 mTaxRate = 0.6;
		case LiveInWorkOut:
			 mTaxRate = 0.6;



void GRTax::SetTaxableIncome(float)


float GRTax::GetTaxAmount(void)

return 0;

Here are a few observations.
1: Your class has only public members. You're probably supposed to make the variable members private. (This isn't required by C++, but what's the point of classes if you make the variables public?)
2: You use the word "void" to indicate no arguments, as in GRTax(void). That should be GRTax();
3: You declare only one of your 2 constructors in the class definition. You need to declare them both.
4: The definition of your default constructor begins "GRTax::GRTax(0)". That should be GRTax::GRTax(). What this constructor should do is assign values to the member variables.

Good Luck.

This article has been dead for over six months. Start a new discussion instead.