Question #5102

Problem Statement: You are required to write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 3.50% to 8.00%, with an increment of 0.25. If you enter the loan amount 5,000 for five years, it will display a table as follows:

Loan Amount: 5000

Number of Years: 5

Interest Rate Monthly Payment Total Payment

3.5% 146.51 5274.37

3.75% 147.06 5294.32

4.0% 147.61 5314.31

…

7.75% 156.1 5619.8

8.0% 156.68 5640.54

What is the main purpose of developing this program? Elaborate your steps to solve the problem and determine the input, process and output for the program. Finally write a pseudo-code and draw a flowchart to solve this problem.

Loan Amount: 5000

Number of Years: 5

Interest Rate Monthly Payment Total Payment

3.5% 146.51 5274.37

3.75% 147.06 5294.32

4.0% 147.61 5314.31

…

7.75% 156.1 5619.8

8.0% 156.68 5640.54

What is the main purpose of developing this program? Elaborate your steps to solve the problem and determine the input, process and output for the program. Finally write a pseudo-code and draw a flowchart to solve this problem.

Expert's answer

#include <iostream.h>

#include <conio.h>

#include <math.h>

main(){

float L,ap,mp,tp,C;& //L - loan amount, ap - annual payment, mp - monthly payment, tp - total payment, c - interest rate

int Y,N,i; //Y - loan period in years, N - loan period in months, i - counter

cout<<"Enter the loan amount: ";

cin>>L;

cout<<"Enter the loan period: ";

cin>>Y;

cout<<"InterestRate"<<"& quot;<<"MonthlyPayment"<<"& quot;<<"TotalPayment\r\n";

C = 3.5;

for (i=0;i<=18;i++){

& //the month payment is one-twelfth of an annual payment:

& mp = ( L + ( ( L * C/100 ) * Y ) ) / ( Y * 12 );

& //Let's calculate the total payment:

& tp = mp*12*Y;

& //printing results:

& cout<<C<<"%& quot;<<mp<<"& quot;<<tp<<"\r\n";

& //calculating next interest value:

& C = C+0.25;

& }

getch();

}

#include <conio.h>

#include <math.h>

main(){

float L,ap,mp,tp,C;& //L - loan amount, ap - annual payment, mp - monthly payment, tp - total payment, c - interest rate

int Y,N,i; //Y - loan period in years, N - loan period in months, i - counter

cout<<"Enter the loan amount: ";

cin>>L;

cout<<"Enter the loan period: ";

cin>>Y;

cout<<"InterestRate"<<"& quot;<<"MonthlyPayment"<<"& quot;<<"TotalPayment\r\n";

C = 3.5;

for (i=0;i<=18;i++){

& //the month payment is one-twelfth of an annual payment:

& mp = ( L + ( ( L * C/100 ) * Y ) ) / ( Y * 12 );

& //Let's calculate the total payment:

& tp = mp*12*Y;

& //printing results:

& cout<<C<<"%& quot;<<mp<<"& quot;<<tp<<"\r\n";

& //calculating next interest value:

& C = C+0.25;

& }

getch();

}

Learn more about our help with Assignments: C++

## Comments

## Leave a comment