 I need help with this assignment I do not know what im doing wrong.

Write a program that accepts as input:

The loan amount
The interest rate per year
The monthly payment.
(Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.)

The program then outputs the number of months it would take to repay the loan.

(Note that if the monthly payment is less than the first month’s interest, then after each payment, the loan amount will increase.)

In this case, the program must warn the borrower that the Monthly payment is too low. The loan cannot be repaid.

Code Tags:

 ``1234567891011121314151617181920212223242526272829303132333435`` `````` #include #include using namespace std; int main() { double loan; double rate; double payment; double month; int m; cout << "Enter your loan amount: " << endl; cin >> loan; cout << "Enter your interest rate per year: " << endl; cin >> rate; cout << "Enter your monthly payment: " << endl; cin >> payment; month = rate / 12; while(payment <(loan*month)) {cout << "Monthly payment too low. Loan cannot be repaid." << endl; cout << "Enter your monthly payment: "; cin >> payment; } m = 0; while(loan > 0) {loan = loan -(payment-(loan * rate)); m++; } cout << "At" << rate << "% and payments of \$" << payment << " per month\nit will take" << m << "months to repay the lone\n"; system("pause"); return 0; }``````
Last edited on Use code tags to make your code easier to read, like this:

 ``` Code Tags: [code] //Your Code Here [/code] ```

What's the issue with the code or where are you stuck? Are you intending to enter your interest rate as a percentage or a decimal fraction?

Ah, look:
 (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.)

But that is NOT what you are doing in these lines:
 ``12`` ``````month = rate / 12; while(payment <(loan*month))``````

If you enter 7.2 then your monthly payment would be (7.2/12) of the total loan. I'd call you a loan shark!

Percentages are in hundredths of a whole - you need to accommodate that in your code.

And as @Zapshe says:
- put your code in code tags;
- tell us exactly why you think it is wrong.

Last edited on I think that one of the loops is incorrect because when I run it it skips line 18 and runs my first loop until it crashes. Other than that I don't know what is wrong with it. > it skips line 18
line 18: `cout << "Enter your monthly payment: " << endl;`
¿that line doesn't print to screen?
¿or is the next line `cin >> payment;` the one that doesn't execute? 