1. 程式人生 > >20年每年存入6600,餘額寶4%利率計算

20年每年存入6600,餘額寶4%利率計算

#include <stdio.h>


int main(void)
{
    int i, j;
    double all = 0;


    for (i = 0; i < 20; i++) {
        all += 6600;
        for (j = 0; j < 365; j++) {
            all = all * (1 + 0.04/365);
        }
        printf("Year %d: %.2f\n", i + 1 , all);
    }
    printf("\nBen Jin: %.2f, Li Xi: %.2f\n", 6600.0*20, all - 6600.0 * 20);

}

Year 1: 6869.33
Year 2: 14019.00
Year 3: 21460.42
Year 4: 29205.53
Year 5: 37266.68
Year 6: 45656.82
Year 7: 54389.35
Year 8: 63478.23
Year 9: 72938.02
Year 10: 82783.83
Year 11: 93031.45
Year 12: 103697.24
Year 13: 114798.32
Year 14: 126352.41
Year 15: 138377.97
Year 16: 150894.36
Year 17: 163921.48
Year 18: 177480.19
Year 19: 191592.16
Year 20: 206280.08


Ben Jin: 132000.00, Li Xi: 74280.08