【发布时间】:2011-01-14 16:56:13
【问题描述】:
#loan calculator...just messing around for practice
cls
$choice = 0
while ($choice -ne 1){
[string]$name = read-host "Enter name"
[double]$amount = read-host "Enter loan amount"
[double]$apr = $(0.01 * (read-host "Enter APR"))
[int]$term = read-host "Enter term in months"
$rate = $apr/12
$mr = $rate * [math]::pow((1+$rate),$term) / ([math]::pow((1+$rate),$term)-1) * $amount
write-host "Customer: "$name
write-host `t"Amount: $"$amount
write-host `t"Monthly rate: "$("{0:N2}" -f $rate)"%"
write-host `t"Number of payments: "$term
write-host `t"Monthly payment: $"$("{0:N2}" -f $mr)
write-host `t"Amount paid back: $"$("{0:N2}" -f $($mr*$term))
write-host `t"Interest paid: $"$("{0:N2}" -f $($mr * $term - $amount))
$choice = read-host "Press 1 to quit or anything else to start over"
}
【问题讨论】:
-
我是新来的...我粘贴了格式非常精美的代码/问题,它首尾相连地运行了我的所有行。那是怎么回事?
-
您必须将代码缩进 4 个空格(或选择块和 CTRL-K 以更快地完成)。我为你修好了。