type
TTaxRec=record
StartMoney: Double
//分段起点
TaxRate: Double
//段内税率
end;
const
TaxData:array [0..4] of TTaxRec=(
(StartMoney:0
TaxRate:0),
(StartMoney:2000
TaxRate:0.05),
(StartMoney:3000
TaxRate:0.10),
(StartMoney:5000
TaxRate:0.15),
(StartMoney:10000
TaxRate:0.25)
);
function CalTax( Money: Double
StartLevel: Byte=0): Double;
begin
if (StartLevel>=High(TaxData)) or (Money<=TaxData[StartLevel+1].StartMoney) then
begin
with TaxData[StartLevel] do
Result:=(Money-StartMoney)*TaxRate;
exit;
end;
with TaxData[StartLevel] do
Result:=(TaxData[StartLevel+1].StartMoney-StartMoney)*TaxRate + CalTax(Money,StartLevel+1);
end;