程嶏清单13-5.txt

来自「< linux网络编程工具>>配套源码」· 文本 代码 · 共 32 行

TXT
32
字号
程序清单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 + =
减小字号Ctrl + -
显示快捷键?