home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR22 / JORF21_2.ZIP / PAYMENT.J < prev    next >
Text File  |  1993-07-05  |  2KB  |  55 lines

  1. Class:Payment (Amt,Yrs,Intr,Pmt,Pmt50,Yrs50)
  2.  
  3. Payment:Start
  4.   New (Payment:Pmt)
  5.   Win:Add ("Loan Payment Calculator",5,20)
  6.     String:"Calculate your loan payment amount and years"
  7.     String:"to pay if you added just $50 to the payment."
  8.     String:
  9.     String:"Press the TAB key to get from one field to"
  10.     String:"the next. ENTER will end the program."
  11.  
  12.     Input:"&Loan Amount         ", Row:7 Col:5 Wid:14
  13.       Field:"Pmt->Amt", After:"Payment:Calc(Pmt)"
  14.       Format:"###,###,###.00", Type:"Numeric"
  15.  
  16.     Input:"&Years to Pay        ", Row:8 Col:5 Wid:3
  17.       Field:"Pmt->Yrs", After:"Payment:Calc(Pmt)"
  18.       Format:"###", Type:"Numeric"
  19.  
  20.     Input:"&Percent Interest    ", Row:9 Col:5 Wid:8
  21.       Field:"Pmt->Intr", After:"Payment:Calc(Pmt)"
  22.       Format:"#0.0000%", Type:"Numeric"
  23.  
  24.     Input:"Payment             ", Row:10 Col:5 Wid:14
  25.       Field:"Pmt->Pmt", Before:"Return(Null)"
  26.       Format:"###,###,###.00", Type:"Numeric"
  27.  
  28.     Input:"Adding just $50     ", Row:12 Col:5 Wid:14
  29.       Field:"Pmt->Pmt50", Before:"Return(Null)"
  30.       Format:"###,###,###.00", Type:"Numeric"
  31.  
  32.     Input:"Reduces the years to"  Row:13 Col:5 Wid:3
  33.       Field:"Pmt->Yrs50", Before:"Return(Null)"
  34.       Format:"###", Type:"Numeric"
  35.  
  36.     Button:"    &Done    ", Row:15, Col:16
  37.   Return(Ok)
  38.  
  39. Payment:Calc(Pmt)
  40.   New (Periods,Per_Intr,Payment,Months50)
  41.   Pmt->Pmt = 0
  42.   If (Pmt->Intr > 0 And Pmt->Yrs > 0)
  43.     Periods    = Pmt->Yrs*12
  44.     Per_Intr   = Pmt->Intr/12/100
  45.     Payment    = (Pmt->Amt*Per_Intr) / (1-Num:Pow(1+Per_Intr,(-Periods)))
  46.     Payment    = Num:Int((Payment+.005)*100)/100
  47.     Pmt->Pmt   = Payment
  48.     Pmt->Pmt50 = Payment+50
  49.     Months50   = Num:Log(Pmt->Pmt50/(Pmt->Pmt50-Pmt->Amt*Per_Intr))
  50.     Months50   = Months50/Num:Log(1+Per_Intr)
  51.     Pmt->Yrs50 = Num:Int((Months50/12)*10)/10
  52.     Win:Dsp
  53.   Return (Ok)
  54.  
  55.