problem answer please

When you borrow money to buy a house or a car, or for some other purpose, you repay the loan by making periodic payments over a certain time. Of course the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1000 at the interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. The interest rate per month is 7.2/12 = 0.6%. The first month’s interest on $1000 is 1000 * 0.006 = 6. Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 – 6 = 19. This means that after making the first payment, the loan amount is 1000 – 19 = 981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981* 0.006 = 5.886, that is, approximately $5.89. This implies that the payment towards the principle is 25 – 5.89 = 19.11, and the remaining balance after the second payment is 981 – 19.11 = 961.89. This process is repeated until the loan is paid. Write a program that accepts as input, the loan amount, the interest rate per year, and 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 and with this monthly payment the loan amount could not be repaid.)
This is not a homework site. We won't do your homework for you.

Show us what you have so far and we can help you get past your sticking points.

By the way, this sounds like a fairly straight-forward homework assignment involving loops. Your instructor did a good job explaining all of the steps required for each loop. Translate the instructions into code and we'll give you a hand getting across the finish line if you are still stuck.
#include <iostream>
using namespace std;
void main()
{
double loan_amount, yearly_intrest, monthly_payment;
cout << "enter loan amount" << endl;
cin >> loan_amount;
cout << "enter yearly intrest " << endl;
cin >> yearly_intrest;
cout << "enter monthly payment" << endl;
cin >> monthly_payment;

double monthly_intrest = yearly_intrest / 12;
cout << "loan will be paid on" << (loan_amount / (monthly_intrest - (loan_amount*monthly_intrest))) << " month " << endl;
if (monthly_payment < monthly_intrest)
{
cout << "warning payment is low";
}
}
Please use code tags when posting code. Code tags make it easer to read and comment on your code.

http://www.cplusplus.com/articles/jEywvCM9/

OK, you wrote the input part of your program.

The problem statement talks about calculating interest and subracting the payment every month (or monthly-compounded interest). Part of your line 14 attempts to do this calculation, but it does it wrong and only does it once.

Re-read your problem statement. Nowhere does it say to divide the loan amount by anything. Also, I would change the variable names yearly_intrest and monthly_intrest to yearly_rate and monthly_rate. You will be calculating interest every month, and you don't want to confuse the interest rate with the calculate interest amount.

Start slowly and do this one step at a time. After you have read in the input (that part looks ok, except you might want to verify that all the values are positive), print out just the monthly interest rate, the first month's interest amount, and the remaining principle after the first month's payment. Also print out whether the first month's interest amount is greater than the monthly payment.

After you have completed this step, add in a loop to do this 2 times. Test it with the sample data in the problem statement and make sure you are getting what you expect.

Next, Add a check in your loop to determine whether your error condition is met. If it is, print the warning and break out of the loop

Last, Change the loop to keep going until the load is repaid. Instead of printing out the info, count the number of iterations. Print out the total after you leave the loop.

At each step, if you have problems, come back here, tell us what your struggles are, and ask questions. A specific question will get you good help. Simply pasting code without any context (like you did in your previous post) will likely get ignored by many on this board because we don't know what you need help with. So far you've posted twice on this thread and still haven't asked a question or mentioned what you are struggling with.

Information on looping: http://www.cplusplus.com/doc/tutorial/control/
(look for "Iteration statements (loops)")
Topic archived. No new replies allowed.