Created
June 27, 2017 23:25
-
-
Save andreconghau/850ee1067b39dd52483b745d5ee58069 to your computer and use it in GitHub Desktop.
Return Tax base on Salary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TaxSalary | |
{ | |
// Input 1000000. | |
function salary($gross_local) | |
{ | |
if (!is_numeric($gross_local) && floatval($gross_local)) { | |
die ('Please input is must type Numeric.'); | |
} | |
if ($gross_local < 0) { | |
die ('Number must be greater than 0.'); | |
} | |
if (($gross_local > 0) && ($gross_local <= 5000000)){ | |
$tax = 0; | |
}elseif (($gross_local > 5000000) && ($gross_local <= 15000000)){ | |
$tax = ($gross_local - 5000000) * 0.1; | |
}elseif (($gross_local > 15000000) && ($gross_local <= 25000000)){ | |
$tax = 1000000 + (($gross_local - 15000000) * 0.2); | |
}elseif (($gross_local > 25000000) && ($gross_local <= 40000000)){ | |
$tax = 3000000 + (($gross_local - 25000000) * 0.3); | |
}elseif ($gross_local > 40000000){ | |
$tax = 7500000 + (($gross_local - 40000000) * 0.4); | |
} | |
return $tax; | |
} | |
} | |
$objTax = new TaxSalary(); | |
$tax = $objTax->salary(15000000); | |
print 'Số tiền phải đóng thuế là '.number_format($tax); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment