SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
More Flow Of Control
Exercise:
Programming Projects
Question:9 | ISBN:9780321531346 | Edition: 7

Question

Interest on a loan is paid on a declining balance, and hence a loan with an interest rate of, say, 14% can cost significantly less than 14% of the balance.

Write a program that takes a loan amount and interest rate as input and then outputs the monthly payments and 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 $1,000 a month. If the interest rate is 10%, then each month the interest is one-twelfth of 10% of the remaining balance.

The first month, (10% of $20,000)/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 interest would be (10% of $19,166.67)/12, and so forth. Also have the program output the total interest paid over the life of the loan. Finally, determine what simple annualized percentage of the original loan balance was paid in interest. For example, if $1,000 was paid in interest on a $10,000 loan and it took two years to pay off, then the annualized interest is $500, which is 5% of the $10,000 loan amount. Your program should allow the user to repeat this calculation as often as desired.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Program Code:

#include<iostream>
using namespace std;
void main()
{   
	double intrestRate, loanAmount, simpleIntrest , bal;
	int month;
	char choice;
	do	
	{ 
	  cout<<" Enter total loan:";
	  cin>>loanAmount;
	  cout<<" Enter rate of interest:";
	  cin>>intrestRate;
     cout<<" Monthly payment = "<<(loanAmount/20)<<"\n";
	  simpleIntrest = 0;
	  bal = loanAmount;
	  month = 0;
       while (bal>0)
	  {
	   simpleIntrest +=((intrestRate * bal)/(100 *12));
	   month++;
     bal -=(loanAmount/20)-((intrestRate * bal)/(100 *12));
       if(bal<0)
		bal = 0;
	   cout<<" bal left:  "<<bal<<"\n";
	  }
	  cout<<" Simple annualized interest is:" 
<<((simpleIntrest*100*12)/(loanAmount*month));
	  cout<<" To continue then enter 'y' or 'Y':\n";
	  cin>>choice;
	} while(choice =='y' || choice =='Y');

}

Output:

 

Enter total loan:200000
 Enter rate of interest:18.5
 Monthly payment = 10000
Left balance:  193083
Left balance:  186060
Left balance:  178928
Left balance:  171687
Left balance:  164334
Left balance:  156867
Left balance:  149286
Left balance:  141587
Left balance:  133770
Left balance:  125832
Left balance:  117772
Left balance:  109588
Left balance:  101277
Left balance:  92838.6
Left balance:  84269.9
Left balance:  75569
Left balance:  66734.1
Left balance:  57762.9
Left balance:  48653.4
Left balance:  39403.5
Left balance:  30010.9
Left balance:  20473.6
Left balance:  10789.2
Left balance:  955.559
Left balance:  0
 Simple annualized interest is:9.83287 To continue then enter 'y' or 'Y': n
0 0

Discussions

Post the discussion to improve the above solution.