0

私は非常に悪いですが、実用的な理由でこれが必要です.なぜ私のコードは「revenus」が15000よりも優れているのに常に「2500」を出力するのですか?

それは累進税率についてです。私たちは彼に収入を与え、彼は私たちが支払わなければならない税金を私たちに与えます。スケール 1 : 15,001 € (除外) 未満の税金は対象外です。スケール 2 : 15 001 から 4000 € (含まれている) の間で 10% の税金。スケール 3 : 40 001 から 80 000 € (含まれている) の間で 15% の税金。スケール 3 税 25% 80,000 € (除外) を超えるものは何でも。

これは、if ステートメントの組み合わせによる愚かな構文エラーである可能性があります。明らかなエラーが発生した場合は教えてください。

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
4

1 に答える 1