home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PASSRC.ZIP / AMORT2.PAS < prev    next >
Pascal/Delphi Source File  |  1991-02-04  |  2KB  |  57 lines

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