home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PASCSRC.ZIP / AMORT2.PAS < prev    next >
Pascal/Delphi Source File  |  1988-01-15  |  2KB  |  56 lines

  1. program Amortization_Table;
  2.  
  3. var Month : 1..12;
  4.     Starting_Month : 1..12;
  5.     Balance : real;
  6.     Payment : real;
  7.     Interest_Rate : real;
  8.  
  9. procedure Initialize_Data; (* ****************** initialize data *)
  10. begin
  11.    Balance := 2500.0;
  12.    Starting_Month := 5;
  13.    Payment := 100.0;
  14.    Interest_Rate := 0.13/12.0;
  15. end;
  16.  
  17. procedure Print_Annual_Header; (* *********** print annual header *)
  18. begin
  19.    Writeln('Annual header');
  20. end;
  21.  
  22. procedure Calculate_And_Print; (* *********** calculate and print *)
  23. var Interest_Payment : real;
  24.     Principal_Payment : real;
  25. begin
  26.    if Balance > 0.0 then begin
  27.       Interest_Payment := Interest_Rate * Balance;
  28.       Principal_Payment := Payment - Interest_Payment;
  29.       if Principal_Payment > Balance then begin  (* loan payed off *)
  30.          Principal_Payment := Balance;              (* this month *)
  31.          Balance := 0.0;
  32.       end
  33.       else begin  (* regular monthly payment *)
  34.          Balance := Balance - Principal_Payment;
  35.       end;
  36.       Writeln(Month:5,Payment:10:2,Interest_Payment:10:2,
  37.               Principal_Payment:10:2,Balance:10:2);
  38.    end; (* of if balance > 0.0 then *)
  39. end;
  40.  
  41. procedure Print_Annual_Summary; (* ********* print annual summary *)
  42. begin
  43. end;
  44.  
  45. begin   (* ****************************************** main program *)
  46.    Initialize_Data;
  47.    repeat
  48.       Print_Annual_Header;
  49.       for Month := Starting_Month to 12 do begin
  50.          Calculate_And_Print;
  51.       end;
  52.       Print_Annual_Summary;
  53.       Starting_Month := 1;
  54.    until Balance <= 0.0;
  55. end. (* of main program *)
  56.