Computers and Technology
Computers and Technology, 11.03.2020 02:00, Jxsolvez

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;

}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 00:30, lilobekker5219
Knowing that the central portion of link bd has a uniform cross sectional area of 800 mm2 , determine the magnitude of the load p for which the normal stress in link bd is 50 mpa. (hint: link bd is a two-force member.) ans: p = 62.7 kn
Answers: 2
image
Computers and Technology, 23.06.2019 00:40, QueenKy6050
Consider the following statements: struct nametype{string first; string last; }; struct coursetype{string name; int callnum; int credits; char grade; }; struct studenttype{nametype name; double gpa; coursetype course; }; studenttype student; studenttype classlist[100]; coursetype course; nametype name; mark the following statements as valid or invalid. if a statement is invalid, explain why. a.) student. course. callnum = "csc230"; b.) cin > > student. name; c.) classlist[0] = name; d.) classlist[1].gpa = 3.45; e.) name = classlist[15].name; f.) student. name = name; g.) cout < < classlist[10] < < endl; h.) for (int j = 0; j < 100; j++)classlist[j].name = name; i.) classlist. course. credits = 3; j.) course = studenttype. course;
Answers: 1
image
Computers and Technology, 24.06.2019 08:30, trashellyoung
Why might you choose to create a functional resume
Answers: 1
image
Computers and Technology, 24.06.2019 09:40, anyar
Healthy study habits are best described as
Answers: 1
Do you know the correct answer?
Enhance your program from Exercise 20 by first telling the user

the minimum monthly pay...

Questions in other subjects:

Konu
Physics, 07.05.2021 22:10