In: Computer Science
Module 6 Project A: Stereo Payment Calculator
You have just purchased a stereo system that cost $1,000 on the following credit plan: no down payment, an interest rate of 18% per year (and hence 1.5% per month), and monthly payments of $50.
The monthly payment of $50 is used to pay the interest and whatever is left is used to pay part of the remaining debt.
Debt0= 1000
Interestn = Debtn*0.015
Principaln = 50 - Interestn
Debtn+1 = Debtn - Principaln
Hence, the first month you pay 1.5% of $1,000 in interest. That is $15 in interest. So, the remaining $35 is deducted from your debt, which leaves you with a debt of $965.00. The next month you pay interest of 1.5% of $965.00, which is $14.48. Hence, you can deduct $35.52 (which is $50 – $14.48) from the amount you owe.
Project Requirements
1. Write a user-defined function that will tell you how many months it will take you to pay off the loan, as well as the total amount of interest paid over the life of the loan.
Code to copy:
#include <iostream>
#include<string>
using namespace std;
int main()
{
double loan_amnt, monthly_Pay,
interest_Rate;
double e = 0;
double amnt, b, l, d, i,
interest_Pay;
//inputting values
cout << "Enter the amount of
the loan: $ ";
cin >> loan_amnt;
cout << "Enter the interest
per year: ";
cin >> interest_Pay;
cout << "Enter the monthly
pay: $ ";
cin >> monthly_Pay;
l = loan_amnt;
cout << endl;
cout << endl;
cout << endl;
for(i=1; l>0;i++)
{
interest_Rate =
interest_Pay/100/12;
amnt =
interest_Rate * l;
b = monthly_Pay
- amnt;
cout <<
"Month: " << i << endl;
cout <<
"Principle Interest: " << amnt << endl;
cout <<
"Principle Remaining: $ " << b << endl;
l = l - b;
cout <<
"You still have a balance of: $ " << l << endl;
cout <<
endl ;
d = e +
amnt;
e = d;
}
i = i-1;
if (l < -0.1)
l = l *
-1;
else if (l > 0.1)
l = l * l;
//outputting data
cout << "\nThe total month
is: " << i << endl;
cout << "\nThe total Interest
paid is: " << d << endl;
cout << "\nYou have a credit
of: " << l << endl;
//pause system for a while
system ("pause") ;
return 0;
}
Code Screenshot:
Sample Output Screenshot: