473,805 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loan Payoff Table Help

10 New Member
Greetings,
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 11679
Banfa
9,065 Recognized Expert Moderator Expert
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
Agusta06
10 New Member
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, DecimalInterest Rate, LoanPayment;
int NumberOfMonths, i, MonthlyInterest ;
float MonthlyPayment, InterestPaid;
int main ()
{
cout<<"Please enter the loan amount: ";
cin>>LoanAmount ;
cout<<"Please enter the interest rate: ";
cin>>InterestRa te;
cout<<"Please enter the loan duration in months: ";
cin>>NumberOfMo nths;

DecimalInterest Rate=(InterestR ate/100)/12;
//Formula used: a = [P((1 + r)^n)r]/[(1 + r)^n - 1]
BalanceA=LoanAm ount*(pow((1+De cimalInterestRa te),NumberOfMon ths))*DecimalIn terestRate;
BalanceB=(pow(1 +DecimalInteres tRate,NumberOfM onths))-1;
MonthlyPayment= BalanceA/BalanceB;
cout<< "Monthly Payment on the loan is $"<< MonthlyPayment< < " for "<<NumberOfMont hs<<" months."<<endl;
InterestPaid=(M onthlyPayment*N umberOfMonths)-LoanAmount;
cout<<"For a "<<NumberOfMont hs<<" month amoritization, the interest paid is $"<<InterestPai d<<"."<<endl;

return 0;
}
Oct 16 '06 #3
Banfa
9,065 Recognized Expert Moderator Expert
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
Agusta06
10 New Member
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
Banfa
9,065 Recognized Expert Moderator Expert
Just write some cout statements that output the lines as you want them.
Oct 17 '06 #6
Agusta06
10 New Member
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, DecimalInterest Rate, Newprince, BalanceA,
BalanceB;
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;

DecimalInterest Rate=(InterestR ate/100)/12;
InterestPaid=(M onthlyPayment*N umberOfMonths)-LoanAmount;
Newprince=(Loan Amount+DecimalI nterestRate)-MonthlyPayment;
BalanceA=LoanAm ount*(pow((1+De cimalInterestRa te),NumberOfMon ths))*DecimalIn terestRate;
BalanceB=(pow(1 +DecimalInteres tRate,NumberOfM onths))-1;

return 0;
}

any idea what i should add?
Oct 18 '06 #7
tyreld
144 New Member
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;
  2.  
  3. cout << "MONTH \t PRINCIPLE \t INTEREST \t PAYMENT" << endl;
  4.  
  5. while (LOAN NOT PAID OFF) {
  6.    INCREMENT MONTH;
  7.  
  8.    interest = CALCULATE INTEREST;
  9.  
  10.    total_interest = CALCULATE TOTAL INTEREST SO FAR;
  11.  
  12.    cout << month << "\t" << principal << "\t" << interest << "\t" << payment << endl;
  13.  
  14.    principal = CALCULATE NEW PRINCIPLE;
  15. }
  16.  
  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;
  21.  
Oct 18 '06 #8
Anberlin863
1 New Member
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

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

Similar topics

2
4182
by: JMCN | last post by:
i am running into problems with is the recordset. i have exactly 104 records. when i tested the code, the end result was multiple records for the same loan(ET LN Shortname). where did i go wrong? so i tried a couple of different do... loop statements and ended up getting the same results, that is having multiple records of the same loan(ET LN Shortname). so if anyone has any suggestions, it would be appreciated :) thanks in advance and...
3
7735
by: Serious_Practitioner | last post by:
Happy New Year! I am looking around for an MS-Access based database that will help me manage the collections of 20-30 small loans. I need to be able to create amortization schedules when the loan is first made, and then I need to be able to apply payments to principal and interest as the payments come in. Don't need multi-user capability or Web access. Just want to install the thing, maybe do some minimal customization to suit my...
0
1097
by: clarale | last post by:
Hello Everyone, Could someone helps me. I receive a file from a company sending all the hyperlink attached to an order. I would like to switch that hyperlink from an order to a loan then put it into a folder that my users can view it when they pull up that loan. I know nothing about hyperlink. Could anyone give me some insight how to swap the info but still keep the hyperlink intact? Thanks a bunch.
0
1056
by: Pedro Moreno | last post by:
I created my first Loam amortization schedule in VB.net but now I need to add the rule of 78 to be use in cars loans. I need help with it. Does any body have a sample template or sample code that I could use? Thanks Pedro.
2
7893
by: phjones | last post by:
Need help programming mortagage calculator for 3 different loans 7 year, 15 year and 30 year. using java array I am a beginner with Java, This is what I have so far. Need to know if I am off the path, import java.math.*;//*loan calculator import java.text.*;//*formats numbers public class 3 Mortgage loans { // declare class variable array int mortgage calculator
1
9826
by: phjones | last post by:
please help resolve some error messages code is compling with errors see below the code. I am new at this please help! /** * @(#)3 Mortgage loans.java * * 3 Mortgage loans application * * Phyllis J Jones * Purpose to write a program in Java without a graphical user interface and have
2
4335
by: fatimahtaher | last post by:
Hi, I am new to C# programming and my first assignment requires me to calculate total interest paid on a loan. The user will input the loan, the interest rate per month, and the monthly payment. It has to use a while loop and calculate the following: Total amount of interest paid and the number of months to pay off the loan. I am not a finance major so I have some difficulty with the logistics of how to go about doing this. My code so...
1
2433
by: paradox6996 | last post by:
Ok I've tried to google this but no luck their. I'm writing a program that calculates someones consumer loan. If we use $1000 as principle, and 15%(.15) as the rate and the duration of the loan is 18 months, you would in the end only get $775 because the the interest is deducted from the principle leaving you with 775$ from $1000. The user enters their own principle, rate, and time, and the program is suppose to calculate how much to request by...
2
1485
by: SATHYA JEEVA KANTH | last post by:
i and my friend were given a assignment which ask us to do c++ programme for loan adviser. my lecturer actually didnt taught us properly for this subject bcoz she went for leave bout 2 month. this situation make us unsure what we are doin.so can anyone post to us sample progrrmme c++ for loan adviser. we really need it urgently and desperate 4 tht. i would really appreciate if u all help me ASAP. TQ.
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.