天天看點

實驗2-2-3 計算存款利息 (10 分)

實驗2-2-3 計算存款利息 (10 分)

本題目要求計算存款利息,計算公式為interes**t=money×(1+rat**e)yea**r−money,其中interes**t為存款到期時的利息(稅前),money是存款金額,yea**r是存期,rat**e是年利率。

輸入格式:

輸出格式:

輸入樣例:

1000 3 0.025      

輸出樣例:

interest = 76.89      
#include<stdio.h>
#include<math.h>
int main()
{
    double m,y,r;
    scanf("%lf %lf %lf",&m,&y,&r);
    double sum;
    sum=m*pow(1+r,y)-m;
    printf("interest = %.2lf",sum);
    
    return 0;
}      

繼續閱讀