Hello guys I am a beginner in programming and I have this assignment to count mortgage. The variables given are
Principle: 150k
Monthly Payment: 6648.09
How long: 3 years or 36 months
Code:
#include "stdafx.h"
#include <stdio.h>
int main()
{
/* declare variable */
double principle = 150000.00;
double interest = 0.06;
double payMonthly = 6648.09;
double balance;
int years = 3;
int months = 1;
/* finding multipler */
double multiplier;
multiplier = interest / 12;
/* calculating balance per month */
double monthlyInterest;
double monthlyPayment;
double newBalance;
monthlyInterest = principle * multiplier;
monthlyPayment = payMonthly - monthlyInterest;
newBalance = principle - monthlyPayment;
do
{
monthlyInterest = principle * multiplier;
monthlyPayment = payMonthly - monthlyInterest;
newBalance = principle - monthlyPayment;
printf("Mortgage for the %d month. \n", months);
months = months + 1;
printf("Principle: %.2lf Interest: %.2lf Deduction: %.2lf \n", principle, monthlyInterest, monthlyPayment);
printf("Balance: %.2lf \n", newBalance);
} while (months < 36);
return 0;
}
When I run it, it does the loop but the numbers not updated. How do I go about fixing this?? thank you.