输入本金和年份并算出利息本金和

时间:2021-04-08 05:34:13
//输入本金和年份并算出利息本金和
#include<stdio.h>
int main()
{
    int x,n;
    float y;
    printf("%请输入存入年份1 2 3 5 8:");
    scanf("%d",&n);
    printf("%请输入存入本金:");
    scanf("%d",&x);
    switch(n)
    {
    case 1:
        printf("%d*0.0225*%d+%d=%f\n",n,x,x,n*0.0225*x+x,y);
        break;
    case 2:
        printf("%d*0.0243*%d+%d=%f\n",n,x,x,n*0.0243*x+x,y);
        break;
    case 3:
        printf("%d*0.027*%d+%d=%f\n",n,x,x,n*0.027*x+x,y);
        break;
    case 5:
        printf("%d*0.0288*%d+%d=%f\n",n,x,x,n*0.0288*x+x,y);
        break;
    case 8:
        printf("%d*0.03*%d+%d=%f\n",n,x,x,n*0.03*x+x,y);
        break;
    default:
        printf("Invalid operator!\n");
    }
}