Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please take the followingC++ code and do the following: first tell the user the minimum monthly payment and then prompting the user to enter the

Please take the followingC++ code and do the following:

first tell the user the minimum monthly payment and then prompting the user to enter the monthly payment.

Your last payment might be more than the remaining loan amount and interest on it. In this case, output the actual amount of the last payment. Also, output the total interest paid.

#include

#include

using namespace std;

int main ()

{

double loanAmount;

double interestRate;

double interestRatePerMonth;

double monthlyPayment;

double paymentPrincipal;

int months;

cout << fixed << showpoint;

cout << setprecision(2);

cout << "Enter the loan amount: ";

cin >> loanAmount;

cout << endl;

cout << "Enter the interest rate per year: ";

cin >> interestRate;

cout << endl;

interestRatePerMonth = (interestRate / 100) / 12;

cout << "Enter the monthly payment: ";

cin >> monthlyPayment;

if (monthlyPayment <= loanAmount * interestRatePerMonth)

{

cout << "Monthly payment is too low. The loan cannot be repaid."

<< endl;

return 1;

}

months = 0;

while (loanAmount > 0)

{

paymentPrincipal = monthlyPayment - (loanAmount * interestRatePerMonth);

loanAmount = loanAmount - paymentPrincipal;

months++;

}

cout << "It will take " << months << " months to repay the loan."

<< endl;

return 0;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago