#include <stdio.h>
#include <math.h>
int main() {
float principal, annualRate, monthlyRate, time, monthlyPayment, totalPayment, additionalPayment;
// Get user input
printf("Enter loan amount (Principal): $_________\n\n\n");
scanf("%f", &principal);
printf("Enter annual interest rate: _______%%\n\n\n");
scanf("%f", &annualRate);
printf("Enter loan term (years): _______years\n\n\n");
scanf("%f", &time);
printf("Enter additional monthly payment: $_________\n\n\n\n\n");
scanf("%f", &additionalPayment);
// Convert annual interest rate to monthly and calculate monthly payment
monthlyRate = annualRate / 100 / 12;
monthlyPayment = (principal * monthlyRate) / (1 - pow(1 + monthlyRate, -time * 12));
// Calculate total payment (including additional payments)
totalPayment = 0;
for (int i = 0; i < time * 12; ++i) {
totalPayment += monthlyPayment;
principal -= monthlyPayment - additionalPayment;
monthlyPayment = (principal * monthlyRate) / (1 - pow(1 + monthlyRate, -((time * 12) - i - 1)));
}
printf("\nMonthly Payment: $%.2f\n\n\n", monthlyPayment + additionalPayment);
printf("Total Payment: $%.2f\n\n\n", totalPayment + (time * 12 * additionalPayment));
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: