📄 程嶏清单13-5.txt
字号:
程序清单13-5:useFinance.pl
#!/usr/bin/perl -w
push(@Inc,'pwd');
use Finance;
$loan = 5000.00;
$apr = 3.5; # APR
$year = 10; # in years.
# ----------------------------------------------------------------
# Calculate the value at the end of the loan if interest
# is applied every year.
# ----------------------------------------------------------------
$time = $year;
$fv1 = Finance::FutureValue($loan,$apr,$time);
print "\n If interest is applied at end of year";
print "\n The future value for a loan of \$" . $loan . "\n";
print " at an APR of ", $apr , " for ", $time, " years";
printf " is %8.2f \n" , $fv1;
# ----------------------------------------------------------------
# Calculate the value at the end of the loan if interest
# is applied every month.
# ----------------------------------------------------------------
$rate = $apr / 12; # APR
$time = $year * 12; # in months
$fv2 = Finance::FutureValue($loan,$rate,$time);
print "\n If interest is applied at end of each month";
print "\n The future value for a loan of \$" . $loan . "\n";
print " at an APR of ", $apr , " for ", $time, " months";
printf " is %8.2f \n" , $fv2;
printf "\n The difference in value is %8.2f", $fv2 - $fv1;
printf "\n Therefore by applying interest at shorter time periods";
printf "\n we are actually getting more money in interest.\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -