Im very bad but I need this for practical reason : why does my code always prints "2500" when 'revenus" is superior to 15000 ?
It's about progressive tax scale : we give him a revenue, and he gives us the tax we have to pay. Scale 1 : NOT any tax under 15 001 € (excluded). Scale 2 : Tax 10% between 15 001 and 4000 € (includeds). Scale 3 : Tax 15% between 40 001 and 80 000 € (included). Scale 3 Tax 25% whatever is above 80 000 € (excluded).
This could be some stupid syntax error because of the combination of the if statements, tell me if you see some blatant error.
revenus = 17305
copyrevenus = 17305
impots = 0
taux1 = 0/100
taux2 = 10/100
taux3 = 15/100
taux4 = 25/100
full1 = 0 #When the first scale is fully filled (superior or equal to the scale's max amount) i don't bother with multiplication, so this is for 15 000 * taux1 etc.
full2 = 2500
full3 = 6000
if copyrevenus > 15000
impots += full1
revenus - 15000
if copyrevenus > 40000
impots += full2
revenus - 25000
if copyrevenus > 80000
impots += full3
revenus - 40000
impots += revenus * taux4
else
impots += revenus * taux3
end
else
impots += revenus * taux2
end
else
impots = revenus * taux1
end
puts impots
Aucun commentaire:
Enregistrer un commentaire