go语言计算债券资本成本

278阅读模式

如题:

某公司5年前发行了面值为1000元、利率为10%、期限为15年的长期债券,每年付息一次,刚支付上年利息,目前市价为950元,公司所得税税率为25%,则该公司债务成本是( ) (题目摘自中华会计网校,如有侵权行为,请告知删除)文章源自懂站帝-http://www.sfdkj.com/19185.html

A: 11.14% B:10.86% C:8.14% D:8.36%文章源自懂站帝-http://www.sfdkj.com/19185.html

1,计算复利现值函数:文章源自懂站帝-http://www.sfdkj.com/19185.html

func Pv( fv float64, year int, cost float64) ( pv float64) {文章源自懂站帝-http://www.sfdkj.com/19185.html

pv = fv文章源自懂站帝-http://www.sfdkj.com/19185.html

for i := 0; i < year; i++ {文章源自懂站帝-http://www.sfdkj.com/19185.html

pv /= 1 + cost文章源自懂站帝-http://www.sfdkj.com/19185.html

}文章源自懂站帝-http://www.sfdkj.com/19185.html

return文章源自懂站帝-http://www.sfdkj.com/19185.html

}文章源自懂站帝-http://www.sfdkj.com/19185.html

2,计算年金现值函数:文章源自懂站帝-http://www.sfdkj.com/19185.html

func PvOfAnnuity( parValue float64, interestRate float64, year int, cost float64) (pvOfAnnuity float64) {文章源自懂站帝-http://www.sfdkj.com/19185.html

annuity := parValue * interestRate文章源自懂站帝-http://www.sfdkj.com/19185.html

pvOfAnnuity = Pv( parValue, year, cost )文章源自懂站帝-http://www.sfdkj.com/19185.html

for i := 1; i <= year; i++ {文章源自懂站帝-http://www.sfdkj.com/19185.html

pvOfAnnuity += Pv( annuity, i, cost)文章源自懂站帝-http://www.sfdkj.com/19185.html

}文章源自懂站帝-http://www.sfdkj.com/19185.html

return文章源自懂站帝-http://www.sfdkj.com/19185.html

}文章源自懂站帝-http://www.sfdkj.com/19185.html

然后穷举法计算cost,为减少计算时间,默认从最小的0.08开始文章源自懂站帝-http://www.sfdkj.com/19185.html

func main(){

var (

price float64 = 950

parValue float64 = 1000

interestRate float64 = 0.1

cost float64 = 0.08

year int = 10

)

for {

cost += 0.00001 //精确到十万分之1

if PvOfAnnuity( parValue, interestRate, year, cost) >= price && PvOfAnnuity( parValue, interestRate, year, cost+0.00001) < price {

fmt.Printf("%.2f%%", 100*cost*0.75)

break

}

}

}

打印结果显示为 8.13%

答案选C. (电脑计算结果比插值法更精确)

懂站帝
  • 本文由 发表于 2022年7月10日 12:30:58
  • 版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至395045033@qq.com举报,一经查实,本站将立刻删除。
评论  0  访客  0