78s

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Finance

This program calculates loan interest rebates using the Rule of 78s method, a standard technique for determining how much finance charge is refunded when a loan is paid off early. The user inputs the original loan term in months, the payment number at which prepayment occurs, the total finance charge, and the monthly payment amount. The core formula at line 200 computes the interest rebate for the remaining period using the sum-of-digits weighting characteristic of the Rule of 78s. Results are rounded to the nearest cent using the classic INT(X*100+0.5)/100 idiom before display.


Program Structure

The program is organized into four logical blocks separated by line-number ranges:

  • Lines 1–10: Title REM and screen clear.
  • Lines 100–135: Input section with inline validation loops.
  • Lines 200–250: Calculation of rebate and outstanding balance.
  • Lines 300–410: Output display and keypress-to-restart loop.

Input Validation

Each of the four inputs is guarded by an immediate conditional branch back to the INPUT line if the value is out of range. Line 115 rejects payment numbers that are zero or exceed the total loan term (K>N OR K=0). The other three inputs (lines 105, 125, 135) simply reject non-positive values. This keeps validation tight and avoids separate error-handling subroutines.

The Rule of 78s Formula

The Rule of 78s allocates finance charges across loan payments in proportion to the sum of digits of the remaining term. The key calculation spans three lines:

  1. Line 200: I = ((2*(N-K+1)) / (N*(N+1))) * P — computes the interest portion attributable to the remaining N-K+1 payments using the ratio of the remaining sum-of-digits to the total sum-of-digits. The total sum of integers 1 through N equals N*(N+1)/2, so multiplying by 2 in the numerator and N*(N+1) in the denominator correctly derives the weighted fraction.
  2. Line 210: RB = ((N-K)*I) / 2 — this attempts to derive a rebate from I by averaging over the remaining periods. However, this secondary calculation introduces a logical inconsistency (see Bugs section below).
  3. Line 220: BL = ((N-K)*MP) - RB — estimates the outstanding principal as total remaining payments minus the computed rebate.

Rounding

Lines 230–250 apply the standard banker’s-style cent-rounding idiom INT(X*100+0.5)/100 to each of the three computed values before display. This avoids floating-point artifacts in the printed output, ensuring results appear as clean dollar-and-cent figures.

Display and Loop

Line 400 implements a busy-wait keypress loop using INKEY$: the program spins until any key is pressed, then jumps back to line 10 to restart. This is a common idiom for pausing on a results screen without requiring a dedicated PAUSE command.

Notable Techniques

  • Line-number grouping (100s, 200s, 300s) provides clear visual separation of program phases and leaves room for future expansion within each block.
  • Validation is performed immediately after each INPUT rather than consolidated, keeping each check close to its corresponding prompt.
  • No subroutines are used; the program is entirely linear with conditional branches for validation and looping.

Bugs and Anomalies

The formula on line 210 (RB = ((N-K)*I)/2) does not correctly compute the interest rebate under the Rule of 78s. The value I already represents the total remaining finance charge attributable to the remaining term; dividing a portion of it by 2 produces an intermediate approximation rather than the true rebate. A correct implementation would set RB = I directly (the full remaining finance charge is the rebate). As a consequence, the outstanding balance at line 220 will be overstated, since it subtracts a smaller-than-correct rebate from total remaining payments.

Additionally, the PRINT statement on line 310 uses a semicolon mid-string ("Rule of 78's;Loan Interest Rebate"), which is embedded inside the string literal and prints literally as a semicolon character rather than acting as a PRINT separator — this is intentional formatting, not a bug, but may look unusual in the listing.

Image Gallery

Source Code

    1 REM "78's"
   10 CLS 
  100 INPUT "Original Number of Months in Loan";N
  105 IF N<=0 THEN GO TO 100
  110 INPUT "Payment No. When Prepayment Occurs";K
  115 IF K>N OR K=0 THEN GO TO 110
  120 INPUT "Original Total Finance Charge";P
  125 IF P<=0 THEN GO TO 120
  130 INPUT "Monthly Payment";MP
  135 IF MP<=0 THEN GO TO 130
  200 LET I=((2*(N-K+1))/(N*(N+1)))*P
  210 LET RB=((N-K)*I)/2
  220 LET BL=((N-K)*MP)-RB
  230 LET II=INT (I*100+0.5)/100
  240 LET R=INT (RB*100+0.5)/100
  250 LET B=INT (BL*100+0.5)/100
  300 CLS 
  310 PRINT "Rule of 78's;Loan Interest Rebate"
  320 PRINT 
  330 PRINT "Original Finance Charge $";  P
  340 PRINT "Original Number of Payments";N
  350 PRINT "Prepayment Month No.       ";K 
  360 PRINT "Rebate Due                $";R  
  370 PRINT "Principal Outstanding      $";B
  400 IF INKEY$="" THEN GO TO 400
  410 GO TO 10

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.