CODE
#include <stdio.h>
int
main(void)
{
double princ_amt; /* Principle amount borrowed */
double airate; /* Annual interest rate */
double mirate; /* Monthly interest rate */
double m_int; /* Monthly interest */
double m_pay; /* Monthly payments */
double remain_amt; /* Remaining after paying interest */
double tot_int; /* Total intrest on loan */
int month; /* How many months it will take to complete payment */
/* Get principle amount */
printf("Enter a principle amount: ");
scanf("%lf", &princ_amt);
/* Gets annual interest rate */
printf("Enter an annual interest rate: ");
scanf("%lf", &airate);
/* Converts annual interest to monthly */
mirate = airate / 1200;
/* Computes monthly interest amount */
m_int = mirate * princ_amt;
/* Shows user the amount of the first months intrest */
printf("Your first month of intrest will be: %.2f\n", m_int);
/* Gets monthly payment */
printf("Enter the amount of your monthly payment: ");
/* Shows how much the user borrowed */
printf("You borrowed $%.2f\n", princ_amt);
scanf("%lf", &princ_amt);
/* Loops until monthly payments are larger than amount left */
month = 0;
tot_int = 0;
m_pay = m_pay;
while (princ_amt > m_pay)
{
m_int = mirate * princ_amt; /* calculating monthly interest */
remain_amt = m_pay - m_int; /* calculating remainder after paying interest */
month = month + 1; /* calculating the months it take to complete */
tot_int += m_int; /* calculating the full interest */
princ_amt = princ_amt - remain_amt; /* paying the loan itself */
}
printf("Your payment schedule consists of %d payments of $%.2f and a final prinicipal payment of $%.2f.\n", month, m_pay, princ_amt);
printf("The total amount of interest you pay will be $%.2f\n", tot_int);
return(0);
}
Ok my problem here is in the while loop.
It performs it. But it does not end by itself and i have to type in quit for the rest of the program to continue.
Please help me!!! Im sooo stuck.