/* Calculate monthly payment for an amortized loan with an annual interest rate using a simple model. Emad Arasteh October 17, 2019 */ #include int main() { double loan = 0, interest_rate = 0; double interest = 0, amortization, month_fee; unsigned int years, year_cnt; printf("Please enter your total loan in dollar: "); scanf("%lf", &loan); printf("Please enter interest rate in percentage: "); scanf("%lf", &interest_rate); printf("Please enter number of years for amortization: "); scanf("%u", &years); year_cnt = years; while (year_cnt > 0) { interest = loan * interest_rate/100; amortization = loan / year_cnt; month_fee = (interest + amortization) / 12; printf("Your monthly fee for year %u is: %f \n", years - year_cnt, month_fee); loan -= amortization; year_cnt--; } return 0; }