Thread: Loan Amortization Table Help

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    13

    Loan Amortization Table Help

    Write a program to create an output file containing a customized loan amortization table. Your program will prompt the user to enter the amount borrowed (the principal), the annual interest rate, and the number of payments (n). The payment must be rounded to the nearest cent. After the payment has been rounded to the nearest cent, the program will write to the output file n lines showing how the debt is paid off.

    Code:
    #include <stdio.h>
    #include <math.h>
     
    int main (void)  
    {  
     int num_payments;    // length of the loan  
     int Principle;      // amount of the loan    
     float InterestRate;
     float i, n, p;
     float PaymentAmount;      
        printf("Please enter loan amount: ");
        scanf("%d", &Principle);
     printf("\nPlease enter annual interest rate: ");
     scanf("%f", &InterestRate);
     printf("\nPlease enter the number of payments: ");
     scanf("%d", &num_payments);
        i = InterestRate/12;  
        n = num_payments;  
        p = Principle;  
     while (num_payments>0)
     {
      PaymentAmount = (i*p)/(1-pow((1+i),-n));
      p = p - PaymentAmount + ((i/100)*p);
      n = n-1;
      printf ("\nNumber of Payments: %d           Amount per payment: %f\n", num_payments, PaymentAmount);
      num_payments = num_payments - 1;
     } 
     getchar ();  
     return 0;          
    }
    So far this is what I've came up with but I don't know if it's correct. Any help would be appreciated.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Please use one of the many loan amortization calculators on the net. If it doesn't work, please return and state the input and output that gave you incorrect amounts or segmentation faults.

    I can't say a program is correct without substantial testing, and that is something you need to be doing, for your programs.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program to calculate loan balance table...
    By thebigskysky in forum C Programming
    Replies: 2
    Last Post: 09-23-2013, 01:27 AM
  2. amortization table : rounding errors
    By slee8251 in forum C Programming
    Replies: 7
    Last Post: 02-15-2012, 10:34 AM
  3. Can't stop my program at zero (Loan Table)
    By beachsidefl321 in forum C Programming
    Replies: 10
    Last Post: 06-24-2009, 09:14 PM
  4. Amortization Table
    By jap2010 in forum C++ Programming
    Replies: 4
    Last Post: 11-04-2008, 08:38 AM
  5. Loan Table
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 10:30 PM

Tags for this Thread