home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / elem-c.zip / AMORTIZ3.C < prev    next >
Text File  |  1985-05-18  |  2KB  |  81 lines

  1. /*
  2. amount = starting balance
  3. balance = remaining balance
  4. rate = interest rate per period
  5. rate1 = interest rate per year
  6. payment = monthly payment
  7. principal = payment to principle
  8. interest = payment of interest per period
  9.  
  10. *******************************************************/
  11. /*        declare variables        */
  12.  
  13.     float amount;
  14.     float balance =0;
  15.     float rate1;
  16.     float rate;
  17.     float payment;
  18.     float principal = 0;
  19.     float interest = 0;
  20.  
  21. /*    **************************    */
  22. interest1()    /* call compute and print results    */
  23. {
  24.     
  25.         balance = amount;
  26.         int x =0;
  27.  
  28.         printf(" payment   interest   principal   balance\n");
  29.  
  30.     while (balance >0)    /* call compute and print results */
  31.         {
  32.         compute();
  33.         printf("%8.2f  %8.2f  %8.2f    %8.2f   %d\n",payment, interest,
  34.                                              principal, balance, ++x);
  35.         line();
  36.         
  37.             if (x%12 ==0)    /* pause every 12 payments  */
  38.                 {
  39.                 printf("press return");
  40.                 getchar();
  41.                 }
  42.  
  43.         }
  44.     
  45. }
  46.  
  47.  
  48. /*        compute balance        */
  49.     compute()
  50.         {
  51.  
  52.         if (balance > payment)
  53.             {
  54.             interest = balance * rate;
  55.             principal = payment - interest;
  56.             balance = balance - principal;
  57.             return (interest);
  58.             return (principal);
  59.             return (balance);
  60.             }
  61.         else
  62.             {
  63.             interest = balance * rate;
  64.             payment = balance + interest;
  65.             principal = payment - interest;
  66.             balance = balance - principal;
  67.             return (interest);
  68.             return (payment);
  69.             return (principal);
  70.             return (balance);
  71.             }
  72.         }
  73.  
  74.  
  75. line()
  76.     {
  77.     int x = 0;
  78.         while (x++<=79)
  79.             printf("-");
  80.         
  81.     }