我正在尝试让输出显示付款和余额。
input.equalsIgnoreCase("y")
答案 0 :(得分:1)
我在代码中发现了一些错误,在这里我没有提到你使用的逻辑,只是编码错误。
答案 1 :(得分:0)
试试这个,我评论了我改变的行
#include <stdio.h>
int main (void)
{
float loan_amount, rate, payment, monthly_amount, interest;
int t, i=1;
printf("Enter Loan Amount");
scanf("%f", &loan_amount); // changed %i to %f since loan_amount is a float
printf("Enter Interest rate:");
scanf("%f", &rate);
printf("Enter Monthly Payment:");
scanf("%f", &payment);
printf("Enter number of payments:");
scanf("%d",&t);
while(loan_amount>0) //Changed ; to )
{
interest = loan_amount*rate/12;
monthly_amount = (loan_amount+interest - payment);
if(monthly_amount>0)
printf("Balance remaing after %d payment: $ %.2f\n",i, monthly_amount);
loan_amount = monthly_amount;
i++;
}
return 0;
}