home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 November / pcwk_11_98a.iso / Wtestowe / Money99 / money99.1 / debt / logic.js < prev    next >
Text File  |  1998-07-25  |  17KB  |  558 lines

  1.     // LOAN LIST DATA STRUCTURE
  2.  
  3. function loanRec( bal, rate, pmt )
  4. {
  5.     this.rate = rate / 1200
  6.     this.pmt = pmt
  7.     this.payoffBal = bal // used later for temporary values during payoff calculation
  8.     this.payoffTerm = 0
  9.     this.begTerm = 0
  10.     this.totalPmt = 0
  11.     this.totalIntPmt = 0
  12.     return this
  13. }
  14.  
  15. function loanList()
  16. {
  17.     this.loan = new Array()
  18.     this.length = 5
  19.  
  20.     this.addLoan = loanList_addLoan
  21.     this.totalPayoff = loanList_totalPayoff
  22.     this.calcPayoff = loanList_payoffTerm
  23.     this.calcTotalPmt = loanList_totalPmt
  24.     this.calcTotalIntPmt = loanList_totalIntPmt
  25.  
  26.     return this
  27. }
  28.  
  29. function loanList_addLoan( bal, rate, pmt )
  30. {
  31.     this.loan[ this.loan.length ] = new loanRec( bal, rate, pmt )
  32. }
  33.  
  34. // calculates remaining payoff balance
  35. function loanList_totalPayoff()
  36. {
  37.     total = 0
  38.     for ( var i = 0; i < this.loan.length; i++ )
  39.     {
  40.         total += this.loan[ i ].payoffBal
  41.     }
  42.     return total
  43. }
  44.  
  45. // calculates payoff term
  46. function loanList_payoffTerm()
  47. {
  48.     var tmpNum;
  49.  
  50.     for ( var i = 0; i < this.loan.length; i++ )
  51.     {
  52.         if (this.loan[i].payoffBal != 0) {
  53.             tmpNum = this.loan[i].pmt/(this.loan[i].payoffBal * (-this.loan[i].rate) + this.loan[i].pmt)
  54.             if(tmpNum > 0) {
  55.                 this.loan[i].payoffTerm = Math.log(tmpNum) / Math.log(1+this.loan[i].rate)
  56.                 this.loan[i].payoffTerm = Math.ceil(this.loan[i].payoffTerm)
  57.             }
  58.             else
  59.                 this.loan[i].payoffTerm = -1    // not sufficient payment to cover the interest
  60.         }
  61.     }
  62. }
  63.  
  64. // calculates total payments made so far
  65. function loanList_totalPmt()
  66. {
  67.     var total = 0
  68.     var i
  69.     for(i=0; i<this.loan.length; i++) {
  70.         total += this.loan[i].totalPmt
  71.     }
  72.     return total
  73. }
  74.  
  75. // calculates total interest payment made so far
  76. function loanList_totalIntPmt()
  77. {
  78.     var total = 0
  79.     var i
  80.     for(i=0; i<this.loan.length; i++) {
  81.         total += this.loan[i].totalIntPmt
  82.     }
  83.     return total
  84. }
  85.  
  86.     // CREDIT CARD LIST DATA STRUCTURE
  87.  
  88. function ccRec( bal, rate, fees, pmt )
  89. {
  90.     this.rate = rate / 1200
  91.     this.fees = fees
  92.     this.pmt = pmt
  93.     this.payoffBal = bal // used later for temporary values during payoff calculation
  94.     this.payoffTerm = 0
  95.     this.begTerm = 0
  96.     this.totalPmt = 0
  97.     this.totalIntPmt = 0
  98.     return this
  99. }
  100.  
  101. function ccList()
  102. {
  103.     this.cc = new Array()
  104.     this.length = 5
  105.  
  106.     this.addCC = ccList_addCC
  107.     this.totalPayoff = ccList_totalPayoff
  108.     this.lowest = ccList_lowest
  109.     this.calcPayoff = ccList_payoffTerm
  110.     this.calcTotalPmt = ccList_totalPmt
  111.     this.calcTotalIntPmt = ccList_totalIntPmt
  112.  
  113.     return this
  114. }
  115.  
  116. function highrateOrder( a_ccRec, b_ccRec )
  117. {
  118.     return b_ccRec.rate - a_ccRec.rate // if A should appear before B, return a negative number
  119. }
  120.  
  121. function ccList_addCC( bal, rate, fees, pmt )
  122. {
  123.     this.cc[ this.cc.length ] = new ccRec( bal, rate, fees, pmt )
  124.     arraySort( this.cc, highrateOrder ) // sort the array by rate from highest to lowest
  125. }
  126.  
  127. function ccList_lowest()
  128. {
  129.     return this.cc[ this.cc.length - 1 ]
  130. }
  131.  
  132. // calculates remaining payoff balance
  133. function ccList_totalPayoff()
  134. {
  135.     var total = 0
  136.     for ( var i = 0; i < this.cc.length; i++ )
  137.     {
  138.         total += this.cc[ i ].payoffBal
  139.     }
  140.     return total
  141. }
  142.  
  143. // calculates total payments made so far
  144. function ccList_totalPmt()
  145. {
  146.     var total = 0
  147.     var i
  148.     for(i=0; i<this.cc.length; i++) {
  149.         total += this.cc[i].totalPmt
  150.     }
  151.     return total
  152. }
  153.  
  154. // calculates total interest payment made so far
  155. function ccList_totalIntPmt()
  156. {
  157.     var total = 0
  158.     var i
  159.     for(i=0; i<this.cc.length; i++) {
  160.         total += this.cc[i].totalIntPmt
  161.     }
  162.     return total
  163. }
  164.  
  165. <%
  166. // The payoff term is calculated by forcing the following residual value to be zero.
  167. //
  168. //    Res^[n] = bal*eta^n - p*[eta^(n-1) + eta^(n-2) + ... + 1].
  169. //    where bal is the initial balance, eta is the (1+interest rate), p is the periodic
  170. //    payment amount.
  171. //
  172. // For a given initial balance, interest, and payment, forcing the Residual value to be
  173. // zero yeilds an equation for the number of periods to payoff the loan.
  174. %>
  175. function ccList_payoffTerm()
  176. {
  177.     var tmpNum;
  178.  
  179.     for ( var i = 0; i < this.cc.length; i++ )
  180.     {
  181.         if(this.cc[i].payoffBal != 0) {
  182.             tmpNum = this.cc[i].pmt/(this.cc[i].payoffBal * (-this.cc[i].rate) + this.cc[i].pmt)
  183.             if(tmpNum > 0) {
  184.                 this.cc[i].payoffTerm = Math.log(tmpNum) / Math.log(1+this.cc[i].rate)
  185.                 this.cc[i].payoffTerm = Math.ceil(this.cc[i].payoffTerm)
  186.             }
  187.             else
  188.                 this.cc[i].payoffTerm = -1        // not sufficient payment to cover the interest
  189.         }
  190.     }
  191. }
  192.  
  193. // this function calculates interest payment for a given balance, interest rate, regular
  194. // payment, and term.
  195. function calcIntPmt(bal, rate, pmt, term)
  196. {
  197.     var intPmt, curBal, i, realRate
  198.  
  199.     curBal = bal
  200.     intPmt = 0
  201.     for(i=0; i<term; i++) {
  202.         intPmt += curBal * rate
  203.         curBal = curBal * (1 + rate) - pmt
  204.         if(curBal <= 0)
  205.             break;
  206.     }
  207.     return intPmt
  208. }
  209.  
  210. var sto = parent;
  211.  
  212.  
  213. var irate = sto.rateLoan
  214. var tempRate = irate / 1200
  215. var payment = sto.pmtLoan
  216. var term = sto.termLoan
  217. var fees = sto.feesLoan
  218. var tempTaxRate = sto.taxLoan / 100
  219.  
  220.   // FIRST, CALCULATE THE TOTAL AMOUNT OWED.
  221. var ccl = new ccList()
  222. ccl.addCC( sto.bal1, sto.rate1, sto.fees1, sto.pmt1 )
  223. ccl.addCC( sto.bal2, sto.rate2, sto.fees2, sto.pmt2 )
  224. ccl.addCC( sto.bal3, sto.rate3, sto.fees3, sto.pmt3 )
  225. ccl.addCC( sto.bal4, sto.rate4, sto.fees4, sto.pmt4 )
  226. ccl.addCC( sto.balOther1, sto.rateOther1, sto.feesOther1, sto.pmtOther1 )
  227.  
  228. var ll = new loanList()
  229. ll.addLoan( sto.balAuto1, sto.rateAuto1, sto.pmtAuto1 )
  230. ll.addLoan( sto.balAuto2, sto.rateAuto2, sto.pmtAuto2 )
  231. ll.addLoan( sto.balBoat, sto.rateBoat, sto.pmtBoat )
  232. ll.addLoan( sto.balPersonal, sto.ratePersonal, sto.pmtPersonal )
  233. ll.addLoan( sto.balOther2, sto.rateOther2, sto.pmtOther2 )
  234.  
  235.     // credit card balances
  236. var currentTotal = ccl.totalPayoff()
  237. ccl.calcPayoff()
  238.  
  239.     // loan balances
  240. currentTotal += ll.totalPayoff()
  241. ll.calcPayoff()
  242.  
  243. var totalPmtMonthly = sto.pmt1 + sto.pmt2 + sto.pmt3 + sto.pmt4 + sto.pmtOther1 +
  244.                     sto.pmtAuto1 + sto.pmtAuto2 + sto.pmtBoat + sto.pmtPersonal +
  245.                     sto.pmtOther2
  246.  
  247.     // SECOND, SPLIT UP THE TASK DEPENDING ON WHETHER CALCULATING TERM OR PAYMENT.
  248.  
  249. var totalNewPayments = 0
  250. var totalNewInterest = 0
  251. var totalNewTaxes = 0
  252. if ( sto.cmethod == 0 )        // how long would it take to...
  253. {
  254.     // WE KNOW THE PAYMENT; GET THE TERM OF THE LOAN, PLUS TOTAL INTEREST AND TAXES
  255.     var tempTotal = currentTotal
  256.     var term = 0
  257.     while ( tempTotal > 0 )
  258.     {
  259.         term++
  260.         var thisInterest = tempTotal * tempRate
  261.         var thisTax
  262.  
  263.         if (sto.loanType == 0)
  264.             thisTax = thisInterest * tempTaxRate
  265.         else
  266.             thisTax = 0
  267.  
  268.         totalNewInterest += thisInterest
  269.         totalNewTaxes += thisTax
  270.         if((thisTax+payment) > thisInterest)
  271.             tempTotal += thisInterest - thisTax - payment
  272.         else {
  273.             payment = 0
  274.             break;
  275.         }
  276.     }
  277.     totalNewPayments = payment * term
  278. }
  279. else                        // how much must I pay to...
  280. {
  281.     // WE KNOW THE TERM; GET THE PAYMENT
  282.     var rate =  1 + tempRate
  283.     var tempTotal = 0
  284.     var n = -1
  285.     while ( n < (term - 1) )
  286.     {
  287.         n++
  288.         tempTotal += Math.pow( rate, n )
  289.     }
  290.     var payment = currentTotal * Math.pow(rate, term) / tempTotal
  291.     
  292.         // THEN CALCULATE INTEREST AND TAXES
  293.     tempTotal = currentTotal
  294.     totalNewInterest = 0
  295.     totalNewTaxes = 0
  296.     for ( var n = 0; n < term; n++ )
  297.     {
  298.         var thisInterest = tempTotal * tempRate
  299.         var thisTax = ( sto.loanType == 0 ) ? (thisInterest * tempTaxRate) : 0
  300.         totalNewInterest = totalNewInterest + thisInterest
  301.         totalNewTaxes = totalNewTaxes + thisTax
  302.         tempTotal = tempTotal + thisInterest - thisTax - payment
  303.     }
  304.     totalNewPayments = (payment * term) + fees
  305. }
  306.  
  307. loanMonths = term
  308. var numDebts = ccl.cc.length + ll.loan.length
  309. var totalLength = 0
  310. var prevTerm, prevPmt
  311. var    loanTerm, crdTerm, loanIndex, crdIndex
  312.  
  313. while(numDebts > 0) {
  314.  
  315.     // find the shortest payoff term from both credit card and conventional loans
  316.     loanTerm = crdTerm = 10000
  317.     loanIndex = crdIndex = 10000
  318.     for(var i=0; i<ccl.cc.length; i++) {
  319.         var crd = ccl.cc[i]
  320.         if((crd.payoffTerm>0) && (crd.payoffTerm!=0) && (crd.payoffTerm < crdTerm)) {
  321.             crdTerm = crd.payoffTerm
  322.             crdIndex = i
  323.         }
  324.     }
  325.  
  326.     if(crdIndex == 10000) {
  327.         for(var i=0; i<ll.loan.length; i++) {
  328.             var loan = ll.loan[i]
  329.             if((loan.payoffTerm>0) && (loan.payoffTerm!=0) && (loan.payoffTerm < loanTerm)) {
  330.                 loanTerm = loan.payoffTerm
  331.                 loanIndex = i
  332.             }
  333.         }
  334.     }
  335.  
  336.     // leave if nothing is to be done
  337.     if((loanTerm==10000) && (crdTerm==10000))
  338.         break;
  339.  
  340.     // set the payoffTerm to be zero to indicate the credit card or loan is paid off
  341.     if(crdTerm != 10000) {
  342.         prevTerm = ccl.cc[crdIndex].payoffTerm
  343.         prevPmt = ccl.cc[crdIndex].pmt
  344.         ccl.cc[crdIndex].totalIntPmt += calcIntPmt(ccl.cc[crdIndex].payoffBal, 
  345.                     ccl.cc[crdIndex].rate, prevPmt, prevTerm)
  346.  
  347.         ccl.cc[crdIndex].totalPmt += ccl.cc[crdIndex].payoffBal + ccl.cc[crdIndex].totalIntPmt
  348.         ccl.cc[crdIndex].payoffTerm = 0
  349.         totalLength += prevTerm
  350.     }
  351.     else {
  352.         prevTerm = ll.loan[loanIndex].payoffTerm
  353.         prevPmt = ll.loan[loanIndex].pmt
  354.         ll.loan[loanIndex].totalIntPmt += calcIntPmt(ll.loan[loanIndex].payoffBal, 
  355.                     ll.loan[loanIndex].rate, prevPmt, prevTerm)
  356.  
  357.         ll.loan[loanIndex].totalPmt += ll.loan[loanIndex].payoffBal + ll.loan[loanIndex].totalIntPmt
  358.         ll.loan[loanIndex].payoffTerm = 0
  359.         totalLength += prevTerm
  360.     }
  361.  
  362.     // get the shortest payoff term and let its payment to cover the highest interest
  363.     // loan from this point and on.  Note the "other loan" index is offset by the
  364.     // length of the credit card.  The reason being that is to be in sync. with the
  365.     // second period payment that's coming.
  366.     var maxIndex = ccl.cc.length + ll.loan.length
  367.     for(var i=0; i<maxIndex; i++) {
  368.  
  369.         if(i < ccl.cc.length) {
  370.             if(ccl.cc[i].payoffBal != 0) {    // assume the rates are sorted already
  371.                 // calc payments made so far
  372.                 if(i != crdIndex) {
  373.                     var curTerm = prevTerm - ccl.cc[i].begTerm
  374.                     var eta = 1 + ccl.cc[i].rate
  375.                     var etan = Math.pow(eta, curTerm)
  376.                     var tmpBal = ccl.cc[i].payoffBal*etan - ccl.cc[i].pmt*((1-etan)/(1-eta))
  377.  
  378.                     if(tmpBal > 0) {    // make sure the following loan still needs to be paid
  379.                         ccl.cc[i].payoffBal = tmpBal
  380.                         ccl.cc[i].totalIntPmt += calcIntPmt(ccl.cc[i].payoffBal, ccl.cc[i].rate, 
  381.                                                     ccl.cc[i].pmt, curTerm)
  382.                         ccl.cc[i].totalPmt += ccl.cc[i].pmt * curTerm
  383.                         ccl.cc[i].pmt = prevPmt + ccl.cc[i].pmt
  384.                         ccl.cc[i].begTerm = prevTerm
  385.                         if(crdIndex != 10000)
  386.                             ccl.cc[crdIndex].payoffBal = 0
  387.                         ccl.calcPayoff()        // recalculate payoff term
  388.                         break;
  389.                     }
  390.                     else {    // this is a case when straight forward payoff is made.
  391.                         ccl.cc[i].totalIntPmt += calcIntPmt(ccl.cc[i].payoffBal, ccl.cc[i].rate, 
  392.                                                     ccl.cc[i].pmt, curTerm)
  393.                         ccl.cc[i].totalPmt += ccl.cc[i].payoffBal + ccl.cc[i].totalIntPmt
  394.                         ccl.cc[i].payoffTerm = 0
  395.                         continue
  396.                     }
  397.                 }
  398.                 else {
  399.                     ccl.cc[crdIndex].payoffBal = 0
  400.                     continue
  401.                 }
  402.             }
  403.         }
  404.         else {
  405.             j = i - ccl.cc.length
  406.             if(ll.loan[j].payoffBal != 0) {
  407.                 // calc payments made so far
  408.                 if(j != loanIndex) {
  409.                     var curTerm = prevTerm - ll.loan[j].begTerm
  410.                     var eta = 1 + ll.loan[j].rate
  411.                     var etan = Math.pow(eta, curTerm)
  412.                     var tmpBal = ll.loan[j].payoffBal*etan - ll.loan[j].pmt*((1-etan)/(1-eta))
  413.  
  414.                     if(tmpBal > 0) {
  415.                         ll.loan[j].payoffBal = tmpBal
  416.                         ll.loan[j].totalIntPmt += calcIntPmt(ll.loan[j].payoffBal, ll.loan[j].rate, 
  417.                                                     ll.loan[j].pmt, curTerm)
  418.                         ll.loan[j].totalPmt += ll.loan[j].pmt * curTerm
  419.                         ll.loan[j].pmt = prevPmt + ll.loan[j].pmt
  420.                         ll.loan[j].begTerm = prevTerm
  421.                         if(loanIndex != 10000)
  422.                             ll.loan[loanIndex].payoffBal = 0
  423.                         ll.calcPayoff()            // recalculate payoff term
  424.                         break;
  425.                     }
  426.                     else {
  427.                         ll.loan[j].totalIntPmt += calcIntPmt(ll.loan[j].payoffBal, ll.loan[j].rate, 
  428.                                                     ll.loan[j].pmt, curTerm)
  429.                         ll.loan[j].totalPmt += ll.loan[j].payoffBal + ll.loan[j].totalIntPmt
  430.                         ll.loan[j].payoffTerm = 0
  431.                         continue
  432.                     }
  433.                 }
  434.                 else {
  435.                     ll.loan[loanIndex].payoffBal = 0
  436.                     continue
  437.                 }
  438.             }
  439.         }
  440.     }
  441.  
  442.     numDebts--;
  443. }
  444.  
  445. termBalance = ccl.totalPayoff() + ll.totalPayoff()
  446.  
  447.     // FINALLY, FILL THE FIELDS ON THE LAST PAGE.
  448. var totalOldCrdPmt=0
  449. var totalOldLoanPmt=0
  450. var totalOldCrdBal=0
  451. var totalOldLoanBal=0
  452.  
  453. // if total payoff balance is not zero, but the payment is zero --> a not 
  454. // sufficient payment condition
  455. totalOldCrdPmt = ccl.calcTotalPmt()
  456. for(var i=0; i<ccl.cc.length; i++)
  457.     totalOldCrdBal += ccl.cc[i].payoffBal
  458.  
  459. if((totalOldCrdBal>0) && (totalOldCrdPmt==0))
  460.         payment = 0        // flag a not sufficient payment error condition
  461.  
  462. totalOldLoanPmt = ll.calcTotalPmt()
  463. for(var i=0; i<ll.loan.length; i++)
  464.     totalOldLoanBal += ll.loan[i].payoffBal
  465.     
  466. if((totalOldLoanBal>0) && (totalOldLoanPmt==0))
  467.         payment = 0        // flag a not sufficient payment error condition
  468.  
  469. var totalOldPayments = totalOldCrdPmt + totalOldLoanPmt
  470. var totalOldInterest = ccl.calcTotalIntPmt() + ll.calcTotalIntPmt()
  471.  
  472. var totalOldFees = 0
  473. for(var i=0; i<ccl.cc.length; i++)
  474.     totalOldFees += ccl.cc[i].fees
  475.  
  476. var loanType = ( sto.loanType == 0 ) ? 'home equity' : 'personal'
  477. var loanRate = irate
  478. var loanPmt = numToDollars( Math.round(payment) )
  479.  
  480. var payoffLenBefore = Math.round( totalLength )
  481. var payoffLenAfter = loanMonths
  482. var paymentBefore = intToDollarStr( Math.round( totalOldPayments - totalOldInterest) )
  483. var paymentAfter = intToDollarStr( Math.round( totalOldPayments - totalOldInterest ) )
  484. var interestBefore = intToDollarStr( Math.round( totalOldInterest ) )
  485. var interestAfter = intToDollarStr( Math.round( totalNewInterest ) )
  486. var feesBefore = intToDollarStr(totalOldFees)
  487. var feesAfter = intToDollarStr(fees)
  488. var taxesBefore = intToDollarStr( 0 )
  489. var taxesAfter = intToDollarStr( Math.round( totalNewTaxes ) )
  490. var totalBefore = intToDollarStr( Math.round( totalOldPayments + totalOldFees) )
  491. var totalAfter = intToDollarStr( Math.round( (totalOldPayments - totalOldInterest) + totalNewInterest + fees - totalNewTaxes ) )
  492.  
  493.  
  494. //logic transferred from pg_5.asp to logic.js
  495. var resultStr = '';
  496.  
  497. if(payment != 0) {
  498.     if(totalBefore < totalAfter) {
  499.         if (sto.cmethod == 0){
  500.             resultStr = "If you consolidate your debts into one " + loanType + " loan (with"
  501.                 + " an interest rate of " + loanRate + "% and a monthly contribution of "
  502.                 + loanPmt + "), it will take you " + loanMonths + " months to pay off all your debts.";
  503.         }
  504.         else{
  505.             resultStr = "If you consolidate your debts into one " + loanType + " loan (with"
  506.                 + " an interest rate of " + loanRate + "% and making payments for "
  507.                 + loanMonths + " months) you need to pay " + loanPmt + " per month to pay off all your debts.";
  508.         }
  509.     }
  510.     else {
  511.         var saved = dollarStrToInt(totalBefore) - dollarStrToInt(totalAfter)
  512.         if (sto.cmethod == 0){
  513.             resultStr = "If you consolidate your debts into one " + loanType + " loan (with"
  514.                 + " an interest rate of " + loanRate + "% and a monthly contribution of "
  515.                 + loanPmt + "), it will take you " + loanMonths + " months to pay off all your debts. "
  516.                 + "You will save $" + saved + " consolidating your debt.";
  517.         }
  518.         else{
  519.             resultStr = "If you consolidate your debts into one " + loanType + " loan (with"
  520.                 + " an interest rate of " + loanRate + "% and making payments for "
  521.                 + loanMonths + " months) you need to pay " + loanPmt + " per month to pay off all your debts."
  522.                 + "You will save $" + saved + " consolidating your debt.";
  523.         }
  524.     }
  525. }
  526. else {
  527.     resultStr ="There is not enough payment made to either the consolidated or unconsolidated loan to cover the "
  528.         + "interest itself.  Please increase the payment amount and recalcuate.";
  529. }
  530.  
  531.  
  532. //calculation for Summary Page
  533. var ansStr = '';
  534.  
  535. if(payment != 0) {
  536.     if (sto.cmethod == 0){
  537.        ansStr = "If you consolidate your debts into one " + loanType + " loan,"
  538.         + " <b>paying " + numToDollars(payment) + " a month,</b> it will take you"
  539.         + " <b>" + numToUnits(payoffLenAfter, 'months') + "</b> and cost " + totalAfter
  540.         + " to pay off all your debts. Paying " + numToDollars(totalPmtMonthly) + " a month on your current loans,"    
  541.         + " it will take you " +  numToUnits(payoffLenBefore, 'months') + " and"
  542.         + " cost " + totalBefore + " to pay off all your debts.";
  543.     }
  544.     else{
  545.        ansStr = "If you consolidate your debts into one " + loanType + " loan,"
  546.         + " you must pay <b>" + numToDollars(payment) + " a month</b> to pay off all you loan"
  547.         + " in " + numToUnits(payoffLenAfter, 'months') + ", it will cost you " + totalAfter
  548.         + ". Paying " + numToDollars(totalPmtMonthly) + " a month on your current loans,"
  549.         + " it will take you " +  numToUnits(payoffLenBefore, 'months') + " and"
  550.         + " cost " + totalBefore + " to pay off all your debts.";
  551.     }
  552. }
  553. else {
  554.     ansStr ="There is not enough payment made to either the consolidated"
  555.     + " or unconsolidated loan to cover the interest itself."
  556.     + " Please increase the payment amount and recalcuate.";
  557. }
  558.