I fixed the issues you guys pointed out (thanks btw!) but now it's giving me an infinite loop. I don't see why. My mortgageleft is getting decreased by the monthlypayment every time the while loop runs...
#include <stdlib.h>
int main(){
float MortgageLeft, InterestRate, MonthlyPayment, MonIntRate, AmountOwed;
int Month=0;
printf("What is the value left on the mortgage?\n");
scanf("%f", &MortgageLeft);
printf("What is the annual interest rate of the loan, in percent?\n");
scanf("%f", &InterestRate);
printf("What is the monthly payment?\n\n");
scanf("%f", &MonthlyPayment);
MonIntRate= (InterestRate/12)/100;
printf("Month\t\t Payment\t\t Amount Owed");
while (MortgageLeft>0){
MortgageLeft=(MortgageLeft*MonIntRate)+MortgageLeft;
if(MortgageLeft>MonthlyPayment)
{
MortgageLeft=MortgageLeft-MonthlyPayment;
Month++;
printf("%d\t\t %.2f\t\t %.2f", Month, MonthlyPayment, MortgageLeft);
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire