编程语言
首页 > 编程语言> > 第2章基本概念8、编程计算第一、二、三月还贷剩余金额

第2章基本概念8、编程计算第一、二、三月还贷剩余金额

作者:互联网

    float loan, rate, payment;
    printf("Enter amount of loan: ");
    scanf("%f", &loan);
    printf("rate: ");
    scanf("%f", &rate);
    printf("payment: ");
    scanf("%f", &payment);

    rate = rate * 0.01 / 12;
    loan = loan + loan * rate - payment;
    printf("first payment: $%.2f\n", loan);
    loan = loan + loan * rate - payment;
    printf("second $%.2f\n", loan);
    loan = loan + loan * rate - payment;
    printf("third $%.2f\n", loan);

标签:基本概念,%.,loan,编程,scanf,还贷,rate,printf,payment
来源: https://www.cnblogs.com/cjbsai/p/14613038.html