编程计算第一、第二、第三个月还贷后剩余的贷款金额:
# includeint main() { double amount;//总贷款金额 double rate;//年利率 double monthlyPayment;//月还款额 double firstPayment = 0;//首月贷款余额 double secondPayment = 0; double thirdPayment = 0; double monthlyRate = 0.01 * 6.0/12;//月利率 printf("Enter amount of loan: "); scanf("%lf", &amount); printf("Enter rate of loan: "); scanf("%lf", &rate); printf("Enter monthlyPayment of loan: "); scanf("%lf", &monthlyPayment); firstPayment = amount - monthlyPayment + amount * monthlyRate; secondPayment = firstPayment - monthlyPayment + firstPayment * monthlyRate; thirdPayment = secondPayment - monthlyPayment + secondPayment * monthlyRate; printf("Balance remaining after first payment: %.2fn",firstPayment); printf("Balance remaining after second payment: %.2fn", secondPayment); printf("Balance remaining after third payment: %.2fn", thirdPayment); }



