subject

Enhance your program from Exercise 20 by first telling 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;

}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:00
When keyboarding, if you want to be fast and accurate you should return your hands on home row with your fingers relaxed and your eyes on the text use only your index fingers to hunt and peck keep your fingers stiff and your eyes on the keys slouch in your chair and keep your fingers hovering over all of the keys
Answers: 2
question
Computers and Technology, 22.06.2019 21:00
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
If you embed a word table into powerpoint, what happens when you make edits to the embedded data? a. edits made to embedded data change the data in the source file; however, edits made to the source file will not be reflected in the embedded data. b. edits made to embedded data will change the data in the source file, and edits made to the source file will be reflected in the embedded data. c. edits made to embedded data don't change the data in the source file, nor will edits made to the source file be reflected in the embedded data. d. edits made to embedded data don't change the data in the source file; however, edits made to the source file will be reflected in the embedded data.
Answers: 1
question
Computers and Technology, 24.06.2019 10:10
Which view in a presentation program displays a split window showing the slide in the upper half and a blank space in the lower half?
Answers: 1
You know the right answer?
Enhance your program from Exercise 20 by first telling the user

the minimum monthly pay...
Questions
question
Mathematics, 23.11.2020 09:30
question
Physics, 23.11.2020 09:30
question
Mathematics, 23.11.2020 09:30
question
Mathematics, 23.11.2020 09:30
question
Mathematics, 23.11.2020 09:30
question
English, 23.11.2020 09:30
Questions on the website: 13722363