Without more information for what the programming language is I cannot give a full answer, so I listed a potential method for calculating salary.
To calculate the salary (Java):
public static double getSalary(double salary) {
if (salary < 40000) {
return salary + (salary * 0.05);
}
return 2000 + ((0.02 * salary) + salary);
}
To calculate the salary (VB .Net):
Function getSalary(ByVal salary As Double) As Double
If salary < 40000 Then
salary = salary + (salary * 0.05)
Else
salary = 2000 + ((0.02 * salary) + salary)
End If
Return salary
End Function