PoshCode Logo PowerShell Code Repository

Get-Payment (modification of post by view diff)
View followups from Stahler | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/707"></script>download | new post

Calculates a loan payment amount given Loan Amount, Interest Rate/Period (i.e. 7.5%/12) and Total number of payments.
Get-Payment 20000 .00625 60

  1. function Get-Payment {
  2.         param ( $LoanAmount, [double]$InterestRatePerPeriod, $NumberPayments )
  3.         $a = $LoanAmount
  4.         $b = $InterestRatePerPeriod*[math]::Pow(($InterestRatePerPeriod + 1),$NumberPayments)
  5.         $c = [math]::Pow((1+$InterestRatePerPeriod),$NumberPayments) - 1
  6.         $payment = $a*($b/$c)
  7.         "{0:C}" -f $payment
  8. }      
  9.  
  10. #

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me