Overall Observations
The program would be simpler if the following functions were members of the Person Class:
- void AddPerson(Person& objPerson)
- void DoYouPayAnnualIncomeTax(Person& objPerson)
- void DoYouPayStudentLoan(Person& objPerson)
- void CalcBandIncomeTaxPayer(Person& objPerson)
- void DisplayResults(Person& objPerson)
In that case the class Person would not need most of the getter and setter functions, and all or most of the attributes / member variables could be private. As members of Person those functions would have direct access to private variables and could skip some intermediate steps.
Example:
void Person::CalcBandIncomeTaxPayer() {
if (m_dAnnualSalary < 11850)
{
m_sBandIncomeTaxName = "Personal Allowance";
m_dTaxRate = 0.0;
}
else if (m_dAnnualSalary < 46350)
{
m_sBandIncomeTaxName = "Basic Rate";
m_dTaxRate = 0.2;
}
else if (m_dAnnualSalary < 150000)
{
m_sBandIncomeTaxName = "Higher Rate";
m_dTaxRate = 0.4;
}
else
{
m_sBandIncomeTaxName = "Additional Rate";
m_dTaxRate = 0.45;
}
}
Addperson should call void DoYouPayAnnualIncomeTax(Person& objPerson) and void DoYouPayStudentLoan(Person& objPerson).
Avoid using namespace std;
The code is inconsistently using std:: there are functions where std::cout is used and then the next line uses cin. Whatever you do, be consistent.
If you are coding professionally you probably should get out of the habit of using the using namespace std; statement. The code will more clearly define where cout and other identifiers are coming from (std::cin, std::cout). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout you may override within your own classes, and you may override the operator << in your own classes as well. This stack overflow question discusses this in more detail.
Magic Numbers
There are Magic Numbers throughout the program, in the CalcBandIncomeTaxPayer() function examples would be: 11850, 0.0, 46350 and 0.2; it would better to create symbolic constants for them to make the code more readblereadable and easier to maintain. These numbers may be used in many places and being able to change them by editing only one line makes maintenance easier.
Numeric constants in code are sometimes referred to as Magic Numbers, because there is no obvious meaning for them. There is a discussion of this on stackoverflow.