function payment= taxpay(salary)

taxhigh=0.4;
taxmid=0.25;
taxlow=0.15;

if salary<=10000
    payment=taxlow*salary;
else if salary<=40000
        payment=taxlow*10000+taxmid*(salary-10000);
    else 
        payment=taxlow*10000+taxmid*30000+taxhigh*(salary-40000);
    end
end