How do I make this puppy work? THis is my assignment: Interest on a loan is paid
ID: 3531416 • Letter: H
Question
How do I make this puppy work?
THis is my assignment:
Interest on a loan is paid on a declining balance, and hence a loan with an interest rate of say, 14 percent can cost significantly less than 14 percent of the palance. Writ a program that takes a loan amount and interest rate as input and then outputs the monthly payments an balance of the loan until the loan is paid off. Assume that the monthly payments are one twentieth of the original loan amount, and that any amount in excess of the interest is credited toward decreasing the balance due. Thus, on a loan of $20,000, the payments would be $1000 a ont. If the intest rate is 10 percent, then each month the intest is one-twelth of 10 percent of the remaining balance. The first month, (10 percent of $2000)/12, or 166.67, would be paid in interest, and the remaining $833.33 would decrease the balance to $19,166.67. The following month the intest would b (10 percent of $19, 166.67)/12, and so forth. Also have the program output the total intest paid over the life of the loan.
// FInally determine what simple annualized percentage of the original loan balance was paid in interest. For example, it $1,000 was paid in interest on a $10,000 loan and it took 2 years to pay off, then the annualized interest is $500, which is 5 percent of the $10,000 loan amount. Your program should allow the user to repeat this calculation as often as desired.
This is my attempt so far, but I always end up with something weird. HOw would I fix this? How would I do the rest of it?:
#include <iostream>
using namespace std;
int main()
{
//assign variables
int month=1;
double original_amount=0, balance=0, interest_rate=1, monthly_payment, monthly_interest;
//prompt user to enter values
cout<< "Enter your loan amount: ";
cin>> original_amount;
cout<< "Enter the interest rate: ";
cin>> interest_rate;
//Calculate each months payments and balance of loan
while (original_amount>0)
{
monthly_payment=original_amount/20;
monthly_interest=(interest_rate*original_amount/12);
balance=original_amount- monthly_payment + monthly_interest ;
month = month++;
cout<< "Balance after " << month << " month: ";
cout<< balance;
balance=original_amount;
break;
}
cout<< " You are all paid off!";
return 0;
}
Explanation / Answer
#include using namespace std; int main() { double monthlyPayment; double balance; double interestRate; int month = 1; cout.setf(ios::fixed); // These lines force currency format in output to 2 decimal pts cout.setf(ios::showpoint); cout.precision(2); cout > balance; cout > interestRate; cout > monthlyPayment; while (interestRate >= 1) { interestRate = interestRate / 100; } balance = balance * (1 + interestRate / 12) - monthlyPayment; // this is where the program stops. coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.