Question

Using basic C++, Find the total amount of payments that are still needed to pay off...

Using basic C++, Find the total amount of payments that are still needed to pay off the loan.

Loan 1:
INPUT
Loan amount: 28781.34
interest rate: 1.99
amount of payments made: 14
years on loan: 5

OUTPUT
periodic payment: 504.35
unpaid balance: 22319.34
payments still needed to pay loan: 46

Loan 2:
INPUT
Loan amount: 33456.12
interest rate: 6.99
amount of payments made: 40
years on loan: 8

OUTPUT
periodic payment: 455.96
unpaid balance: 21734.13
payments still needed to pay loan: 56

Loan 3:
INPUT
Loan amount: 16879.45
interest rate: 3.54
amount of payments made: 120
years on loan: 10

OUTPUT
periodic payment: 167.23
unpaid balance: 0.00
Loan is PAID IN FULL!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
   for(int i=1;i<=3;i++)
   {
       float p,r,pmade,time;
       cout<<"Loan "<<i<<":"<<endl;
       cout<<"Loan Amount: ";
       cin>>p;
       cout<<"interest rate: ";
       cin>>r;
       cout<<"amount of payments made: ";
       cin>>pmade;
       cout<<"years on loan: ";
       cin>>time;
       float n=time*12;
       r = r / (12 * 100);
       float periodicPayment= (p * r * pow(1 + r, n)) / (pow(1 + r, n) - 1); //monthly installment
       float loanAmount=p;
       for (int j = 1; j <= pmade; j++) //to calculate outstading balance
       {
           loanAmount += (loanAmount * r);
           loanAmount -= periodicPayment;
          
       }
       cout<<endl<<"periodic payment: "<<periodicPayment<<endl;
      
       if(loanAmount<=0)
       {
           cout<<"unpaid balance: 0.00 "<<endl;
           cout<<"Loan is PAID IN FULL"<<endl;
          
       }
       else
       {
           cout<<"unpaid balance: "<<loanAmount<<endl;
           cout<<"payments still needed to pay loan: "<<(n-pmade)<<endl<<endl;
       }
   }
  
}

Output:

Add a comment
Know the answer?
Add Answer to:
Using basic C++, Find the total amount of payments that are still needed to pay off...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT