Several issues - beyond the year == day..:
- The for loop initialises CurrentLoan to eg. 5000, and runs as long as CurrentLoan == 0, which is false in all cases, except when the user typed '0' to the Loan Amount question.
- You're incrementing CurrentLoan with one (++CurrentLoan) in each iteration - why?
- you have ';' before '{' in the for loop - causing the content of '{ .. }' after it to be considered a scope inside a function, rather than the actions of the loop. This means it will only execute once the for-loop has completed, and not with each iteration of the for loop.
- Unless the user types in a negative Monthly value, the loan is increased and not reduced?
- you're returning 0, but your main function is specified as void..
A working example (of the loop - I've not done the APR part, as it doesn't seem that this is your question):
int main(int argc, char** argv) {
float LoanAmount;
float Monthly; /*Prompts Number to a Float character type*/
printf("Please enter in the Loan Amount : \n\r"); /*prompts user to enter float*/
scanf("%f", &LoanAmount);
printf("Please enter in the Monthly payment plan : \n\r");
scanf("%f", &Monthly);
printf("\nPerforming calculation using a loan of Loan Amount: %.2f \n\r", LoanAmount);
printf("with a monthly payment of : %.0f \n\r", Monthly);
for (; LoanAmount >= 0; LoanAmount -= Monthly) {
printf("%.2f \n\r", LoanAmount);
}
return (0);
}
Changes:
- Removed excess variables not needed
- Decrease LoanAmount with Monthly in each iteration
- print (remaining) LoanAmount in each iteration
- for loop stops once at/below zero
Output:
Please enter in the Loan Amount :
11111
Please enter in the Monthly payment plan :
1949
Performing calculation using a loan of Loan Amount: 11111.00
with a monthly payment of : 1949
11111.00
9162.00
7213.00
5264.00
3315.00
1366.00