LoginSignup
1
0

More than 3 years have passed since last update.

NISAの積み立てシュミレーションをざっくり書いてみた

Last updated at Posted at 2019-11-28

概要

複利計算が電卓でやると面倒なので、ざっくり書いてみました。
細かいものは省いているのでご容赦ください。:bow_tone1:

参考

コード

//Swift

var year = 0 //現在の継続年数を示す
var targetYear = 30 //継続期間
var beforeMonthlyPrincipal: Double = 33000 //毎月投入金額
var afterMonthlyPrincipal = 100000.0 //税免除後の毎月投入金額
var beforeInterestRate = 1.08 //免除前金利
var afterInterestRate = 0.08 //免除後金利
var assets: Double = 0 //資産
var devidedAmountOfMoney: Double = 0 //配当金額
var realIncome: Double = 0 //実収入
var incomeTax = 0.8 //20%
//税免除時
while year < 20{
    assets += beforeMonthlyPrincipal*12
    assets *= beforeInterestRate
    year += 1
    print("\(year)年: \(Int(assets))円")
}
print("税免除終了時の資産額: \(Int(assets))円")
print("税免除終了時の投入金額: \(Int(Double(year)*(beforeMonthlyPrincipal*12)))円")
//税免除終了時
while year < targetYear {
    assets += afterMonthlyPrincipal*12
    devidedAmountOfMoney = afterInterestRate * assets
    assets += devidedAmountOfMoney * incomeTax
    year += 1
}
print("\(year)年後の資産額: \(Int(assets))円")
print("\(year)年後の投入金額: \(Int(Double(10)*afterMonthlyPrincipal*12) + Int((Double(year)*(beforeMonthlyPrincipal*12))))円")

GitHub

GitHubへのリンク

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0