Your program will ask the user to enter the amount of money they want to borrow, the interest rate, and the monthly payment amount. Your program will then determine how many months it will take to pay off that loan, what the final payment amount will be, and how much interest was paid over that time. If the monthly payment amount isn't high enough to pay off more than one month's interest, your program should notify the user what the minimum monthly payment is.
Here are some examples of how your program should behave. Please use the exact same test cases as these, so that we can verify that your program works:
[cpersiko@fog cs110a]$ python3 consumerLoan.py ** Welcome to the Consumer Loan Calculator ** How much do you want to borrow? $1000 What is the annual interest rate expressed as a percent? 18 What is the monthly payment amount? $50 Your debt will be paid off after 24 months, with a final payment of just $47.83 The total amount of interest you will pay during that time is $197.83 ** Don't get overwhelmed with debt! ** [cpersiko@fog cs110a]$ python3 consumerLoan.py ** Welcome to the Consumer Loan Calculator ** How much do you want to borrow? $15000 What is the annual interest rate expressed as a percent? 10 What is the monthly payment amount? $100 You must make payments of at least $126.00 Because your monthly interest is $125.00 ** Don't get overwhelmed with debt! ** [cpersiko@fog cs110a]$ python3 consumerLoan.py ** Welcome to the Consumer Loan Calculator ** How much do you want to borrow? $-50 You must enter a positive number! How much do you want to borrow? $-200 You must enter a positive number! How much do you want to borrow? $20000 What is the annual interest rate expressed as a percent? -2.5 You must enter a positive number! What is the annual interest rate expressed as a percent? 5 What is the monthly payment amount? $0 You must enter a positive number! What is the monthly payment amount? $200 Your debt will be paid off after 130 months, with a final payment of just $125.79 The total amount of interest you will pay during that time is $5925.79 ** Don't get overwhelmed with debt! ** [cpersiko@fog cs110a]$
Month 1:
$100 * 0.01 = $1 interest for the month
adding interest and subtracting the payment:
$100 + $1 - $50 = $51 new balance
Month 2:
$51 * 0.01 = $0.51 interest for the month
adding interest and subtracting the payment:
$51 + $0.51 - $50 = $1.51 new balance
Month 3:
$1.51 * 0.01 = $0.02 interest for the month (you don't have to
round in your calculations)
adding interest and subtracting the payment:
$1.51 + $0.02 - $50 = -$48.47 new balance
Since the new balance is negative, the loan is paid off, and the final payment is too much. It should have been $50 - $48.47 = $1.53 final payment.
Code:
#include<iostream>
#include<iomanip>
using namespace std;
void get_input(double& principle, double& interest,
double& payment);
double pay_off_loan(double principle, double rate, double
payment,
int& months, double& total_interest);
int main ()
{
double principle, rate, interest=0,payment,final;
int months=0;
cout<<"* Welcome to the Consumer Loan Calculator
*\n\n";
get_input(principle,rate,payment);
if(payment>0)
{final=pay_off_loan(principle,rate,payment,months,interest);
cout<<"Your debt will be paid off after
"<<months<<" months, with a final payment of just
$"
<<setprecision(2)<<fixed<<
final<<endl;
cout<<"The total amount of interest you will pay during that
time is $"
<<setprecision(2)<<fixed<<
interest<<endl;
}
cout<<"\n* Don't get overwhelmed with debt! *\n";
system("pause");
return 0;
}
double pay_off_loan(double principle, double rate, double
payment,
int& months, double& total_interest)
{ double final,interest;
while(payment<=principle*rate+principle)
{interest=principle*rate;
principle=principle-payment+interest;
total_interest+=interest;
months++;
}
if(principle>0)
{interest=principle*rate;
principle=principle+interest;
total_interest+=interest;
months++;
}
return principle;
}
void get_input(double& principle, double&
interest, double& payment)
{double min;
cout<<"How much do you want to borrow?: $";
cin>>principle;
while(principle<=0)
{cout<<"You must enter a positive number!\n";
cout<<"How much do you want to borrow?: $";
cin>>principle;
}
cout<<"What is the annual interest rate expressed as a
percent? ";
cin>>interest;
while(interest<=0)
{cout<<"You must enter a positive number!\n";
cout<<"What is the annual interest rate expressed as a
percent? ";
cin>>interest;
}
interest=interest/100./12.;
min=principle*interest;
cout<<"What is the monthly payment amount? $";
cin>>payment;
while(payment<=0)
{cout<<"You must enter a positive number!\n";
cout<<"What is the monthly payment amount? $";
cin>>payment;
}
if(payment<=min)
{cout<<"You must make payments of at least
$"<<min+1<<endl;
cout<<"Because your monthly interest is
$"<<min<<endl;
payment=-1;
}
}
Output:
Your program will ask the user to enter the amount of money they want to borrow,...
When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that...
C++ Program - Loan Payment Report Please write a C++ program to generate a detail loan payment report from the first month until the loan balance becomes zero or less than ten cents. You may use a while loop such as: while (loanBalance >= monthPayment) { … }. When the loanBalance is less than the monthPayment, you need to compute the final payment amount, which should be the loanBalance plus its interest of one month. For example, if your last-month’s...
using Matlab program: Create a loan payment program that can be used for any loan amount such as a home or car loan. The program should ask the user for the input values below, compute the monthly payment, then compute the monthly balance. Display the balance in a table Month Balance 1 $ ##.## 2 $ ##.## 3 $ ##.## . . . etc Use the formula PMT=P*(r(1+r)^n)/((1+r)^n-1) PMT = the monthly payment. P = the principal r = the interest rate per month, which...
This C++ Program should be written in visual studio 2017 You are to write a program that can do two things: it will help users see how long it will take to achieve a certain investment goal given an annual investment amount and an annual rate of return; also, it will help them see how long it will take to pay off a loan given a principal amount, an annual payment amount and an annual interest rate. When the user...
When you borrow money to buy a house or a car, you pay off the loan in monthly payments, but the interest is always accruing on the outstanding balance. This makes the determination of your monthly payme on a loan more complicated than you might expect. If you borrow P dollars at a monthly interest rate ofras decimal) and wish to pay off the note in months, then your monthly payment M = M(Prt) in dollars can be calculated using...
12. You decide to buy a car that costs $15.000. You want to borrow all the money at a 6.5% (annual) interest rate. You want to pay it in 4 months. Find your monthly payment and write it in the table below. a. Fill in the amortization schedule showing how much of each of your monthly payments go to interest and how much to your principal. Principal: $15,000.00 Interest Rate: 6.50% Payment Interval: Monthly # of Payments: 4 Payment: S...
46) A contour diagram of the monthly payment on a 5 year loan as a function of the interest rate and the amount borrowed is shown in the contour diagram. oan amount (S 8,000 7,000 6,000 120 ,000 ,000 s0 ,000 60 nterest 2,000 1357 9 11 13 15 r Suppose you borrow $5,000 and, since you have a bad credit rating, your loan payment is $100 per month. Suddenly, you get a job at Google and your credit rating...
You borrow $100,000 on a mortgage loan. The loan requires monthly payments for the next 30 years. Your annual loan rate is 4.25%. The loan is fully amortizing. What is your monthly payment? Round your answer to 2 decimal places. 2. You borrow $100,000 on a mortgage loan. The loan requires monthly payments for the next 30 years. Your annual loan rate is 4.25%. The loan is fully amortizing. What is your Month 1 interest payment? Round your answer to...
Assume that you have a 30 year fully-amortized fixed rate mortgage for your home. Your loan amount is $300,000 with a 3% annual interest rate. After 28 years, you would like to sell the property. What is your loan balance at the end of 28 years? Assume that you have a 30 year fully-amortized fixed rate mortgage for your home. Your loan amount is $300,000 with a 3% annual interest rate and your balloon payment is $50,000. What is your...
1. Let's take a specific example. Assume you borrow Bo = $15,000 with a fixed annual interest rate of 6%, or 0.5% per month. As a first problem, assume that your monthly payment is $500. The goal is to compute the number of months required to pay off the loan. Every month, two things happen: Interest, which is 0.5% of the current balance, is added to the current balance and the loan balance is decreased by the monthly payment of...