{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

assign4 - m_int =(y_int/12/100 cout<<"m_int...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <iomanip> # using namespace std; u int main() { //define variables double pmt; //monthly payment double prin; //principal amount double newprin; //updated principal amount after each payment double m_int; //interest rate per month double y_int; //interest rate per year int month = 0; //number of months //input initial loan amount cout << "Loan amount: "; cin >> prin; cout << endl; //input yearly interest rate cout << "Interest rate per year (as a percentage): "; cin >> y_int; cout << endl; //convert yearly interest rate to monthly interest rate
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: m_int = (y_int/12)/100; cout << "m_int = " << m_int << endl; //input monthly payment cout << "Monthly payment: "; cin >> pmt; cout << endl; if (pmt < m_int * prin) { cout << "Your monthly payment is too low." << endl; cout << "Thus, the loan amount can't be repaid." << endl; } else { while (prin > 0) { newprin = prin - pmt + m_int * prin; prin = newprin; month++; cout << month << endl; cout << "New principle = " << newprin << endl; } cout << "Total months needed to pay off loan: " << month << endl; } return 0; }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online