471,873 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

Loan Payoff Table Help

I am working on writing a C++ program and am relatively new in doing so. I am finding computer programming interesting and enjoy learning how to write the source code. If anyone could take the time to aid me in writing my program I would be greatly appreciative.
The purpose of this programming project is to write a C++ program to calculate a car loan payoff table to see how long it would take to pay off a car loan for a given value car. For example, if you borrow $10,000 at an annual interest rate of 12% (12%/12 per month) with a monthly payment of $150, in the first month you will pay $100 interest and still owe $9,950. How many months would it be before the loan is paid off?

Month Principle Interest Payment
1 10,000.00 100.00 150.00
2 9,950.00 99.50 150.00
3 9,899.50 99.00 150.00
4 9,848.50 98.49 150.00

I need to write a program to solve the problem. User input will include the amount of the loan, the interest rate (in percent), and the monthly payment amount, and the program prints out the length of the loan in years and months and the total amount paid in interest over the life of the loan.
Can anyone kindly take a few minutes and give me some help?
Oct 15 '06 #1
8 11410
9,065 Expert Mod 8TB
You seem to have a firm grasp of the problem. Encode it yourself and then if you have a specific problem with your code post the code and the problem here and we will help.
Oct 16 '06 #2
My lab partner and I came up with this code that calculates the interest paid but are unsure how to modify it in order to be able to enter the monthly payment and displays the output in a table. Any ideas?

#include <iostream>
#include <math.h>

float LoanAmount, InterestRate, BalanceA, BalanceB, Payment, DecimalInterestRate, LoanPayment;
int NumberOfMonths, i, MonthlyInterest;
float MonthlyPayment,InterestPaid;
int main ()
cout<<"Please enter the loan amount: ";
cout<<"Please enter the interest rate: ";
cout<<"Please enter the loan duration in months: ";

//Formula used: a = [P((1 + r)^n)r]/[(1 + r)^n - 1]
BalanceA=LoanAmount*(pow((1+DecimalInterestRate),N umberOfMonths))*DecimalInterestRate;
BalanceB=(pow(1+DecimalInterestRate,NumberOfMonths ))-1;
cout<< "Monthly Payment on the loan is $"<< MonthlyPayment<< " for "<<NumberOfMonths<<" months."<<endl;
cout<<"For a "<<NumberOfMonths<<" month amoritization, the interest paid is $"<<InterestPaid<<"."<<endl;

return 0;
Oct 16 '06 #3
9,065 Expert Mod 8TB
My lab partner and I came up with this code that calculates the interest paid but are unsure how to modify it in order to be able to enter the monthly payment and displays the output in a table. Any ideas?
Well you are already inputing 3 values at the start of this code so that should be easy enough for you to copy.

As to the table that is fairly easy, have a calculation variable, set it to the loan amount. Then for each month you can calculate the interest for the month. output the data for that month using a cout statement then adjust the calculation variable by adding the interest and taking off the monthly payment.

At some point you will get the situation of calculation variable + interest - monthly payment < 0. At this point stop the loop, there is a final payment of calculation variable + interest.
Oct 16 '06 #4
i'm trying to get my output to look something like this...

Please enter the following information about your loan:
Amount of loan:____
Annual interest rate:____
Monthly payment:_____

Month Interest Principle Balance
1 etc etc etc

Loan totals:
The loan was paid off in ______ months
Total interest paid_____

Please help?
Oct 17 '06 #5
9,065 Expert Mod 8TB
Just write some cout statements that output the lines as you want them.
Oct 17 '06 #6
thanks for helping me.
I'm still not quite understanding how to get the output.

#include <iostream>
#include <math.h>

int main()
float LoanAmount, InterestRate, DecimalInterestRate, Newprince, BalanceA,
int NumberOfMonths;
float MonthlyPayment,InterestPaid;

cout << "Please Enter the Amount of Loan: ";
cin >> LoanAmount;

cout << "Please Enter the Interest Rate: ";
cin >> InterestRate;

cout << "Please Enter the Monthly Payment: ";
cin >> MonthlyPayment;

BalanceA=LoanAmount*(pow((1+DecimalInterestRate),N umberOfMonths))*DecimalInterestRate;
BalanceB=(pow(1+DecimalInterestRate,NumberOfMonths ))-1;

return 0;

any idea what i should add?
Oct 18 '06 #7
144 100+
If you are trying to create a table of the number of payments like you have outlined in the problem description I would recommend using a loop. Fill in the psuedo code with with real code. I've probably provided you with a bit more then I should.

Expand|Select|Wrap|Line Numbers
  1. int month = 0;
  3. cout << "MONTH \t PRINCIPLE \t INTEREST \t PAYMENT" << endl;
  5. while (LOAN NOT PAID OFF) {
  8.    interest = CALCULATE INTEREST;
  10.    total_interest = CALCULATE TOTAL INTEREST SO FAR;
  12.    cout << month << "\t" << principal << "\t" << interest << "\t" << payment << endl;
  14.    principal = CALCULATE NEW PRINCIPLE;
  15. }
  17. cout << endl;
  18. cout << "Loan Totals:" << endl;
  19. cout << "The loan was paid off in " << months << " months." << endl;
  20. cout << "The total interest paid was $" << total_interest << endl;
Oct 18 '06 #8
hey you guys know how you can make that program(car loan) print out whether you are approved or not...i guess you would have to use an If statement...
Dec 6 '06 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Serious_Practitioner | last post: by
reply views Thread by Pedro Moreno | last post: by
1 post views Thread by phjones | last post: by
1 post views Thread by paradox6996 | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.