Loan Payments

This is a discussion on Loan Payments within the C Programming forums, part of the General Programming Boards category; Compute a table that shows a monthly payback schedule for a loan. The principle amount of the loan, the annual ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    12

    Angry Loan Payments

    Compute a table that shows a monthly payback schedule for a loan. The principle amount of the loan, the
    annual interest rate, and the monthly payment amount are to be read as inputs. Calculate the monthly
    interest rate as 1/12 of the annual rate. Each month, rst calculate the current interest = the monthly
    rate the loan balance. Then add the interest amount to the balance, subtract the payment, and print
    this new balance. Continue printing lines for each month until the normal payment would exceed the
    loan balance. On that month, the payment amount should be the remaining balance and the new balance
    becomes 0. Print a neat loan repayment table following this format:

    Payment schedule for $1000 loan
    at 0.125 annual interest rate
    and monthly payment of $100.00
    Month Interest Payment Balance
    -----------------------------------------
    1 10.42 100.00 910.42
    2 9.48 100.00 819.90
    ... ... ... ...
    10 1.66 100.00 60.99
    11 0.64 61.63 0.00
    -----------------------------------------

  2. #2
    Registered User
    Join Date
    Oct 2012
    Posts
    12
    Code:
    This is what I have so far, but i dont know how to make it into a table.
    
    
    /*#include <stdio.h>
    int main (void)
    {
    	/*float loan_amount, interest_rate, monthly_payment, monthly_amount, interest;
    	int n, i=1;
    
    
    	printf("\n Payment Schedule for $1000 loan \n"
    	" at 0.125 annual interest rate \n"
    	" and monthly payment of $100.00 \n");
    	/*scanf("%i", &loan_amount);
    	printf("Enter Interest rate:");
    	scanf("%f", &interest_rate);
    	printf("Enter Monthly Payment:");
    	scanf("%f", &monthly_payment);
    	printf("Enter number of payments:");
    	scanf("%d",&n);
    
    
    		while(loan_amount>0 && i<=n)
    		{
    			interest = loan_amount*interest_rate/12;
    			monthly_amount = (loan_amount+interest - monthly_payment);
    
    
    			if(monthly_amount>0)
    				printf("Balance remaing after %d payment: $ %.2f\n",i, monthly_amount);
    			loan_amount = monthly_amount;
    			i++;
    		}
    		return 0;
    }*/

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    To make the columns line up smartly, use a fixed width format in printf().

    Code:
    printf("%3d  %.2f  -%5d\n",9 82.56,199); //3d=fixed field 3 digits wide, .2 only print 2 digits after the decimal -%5d, align number to the other side of a 5 digit wide field
    There are several of these, check your help file for many more. This is just an example, not your specific answer.

    And welcome to the forum rmrjr22!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Schedule Loan program?
    By Extrovert in forum C++ Programming
    Replies: 2
    Last Post: 04-22-2005, 05:29 PM
  2. FORMULA for a LOAN
    By OneStiffRod in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 03-22-2003, 09:14 AM
  3. Loan calculation formula
    By C++Nerd in forum C++ Programming
    Replies: 1
    Last Post: 10-06-2002, 12:57 PM
  4. Loan Table
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 09:30 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21