Ok I had to make a loan table where you enter the loan amount, the monthly interest rate, and the amount of the monthly payment, it then prints out a table containing the month, payment, interest, and remaining
I can't get the program to stop when remaining = 0
Here is my code:
Can someone please help me?Code:#include <stdio.h> int main() { double loan_amt; double interest_rate; double remaining; double interest; double payment; int month = 1; printf("Enter the loan amount\n"); scanf("%lf", &loan_amt); printf("Enter the monthly interest rate of the loan\n"); scanf("%lf", &interest_rate); printf("Enter the amount of the monthly payment\n"); scanf("%lf", &payment); printf("+-------+---------+-----------+----------+\n"); printf("| Month | Payment | Interest | Remaining | \n"); printf("+-------+---------+-----------+----------+\n"); interest_rate = (loan_amt*(interest_rate/100)); while(loan_amt > 0) { interest = (loan_amt*(interest_rate/100)); loan_amt = loan_amt+interest; printf("| %3d | %5.2lf | %4.2lf | %.2lf |\n", month, payment, interest, loan_amt); month++; if(payment > (loan_amt + interest)) { interest = (loan_amt*(interest_rate/100)); payment = (loan_amt + interest); loan_amt = 0; printf("| %3d | %5.2lf | %4.2lf | %.2lf |\n", month, payment, interest, loan_amt); } } system("PAUSE"); return 0; }
Thanks, I would really appreciate it.



LinkBack URL
About LinkBacks




1.2 would be 120%, 0.012 would be 1.2%.