• 利息


    #include<stdio.h>
    #include<math.h>
    
    double danli(double i,int N,double P)
    {
        double nlx,F;
        nlx = P*i;
        F = nlx*N + P;
        return F;
    
    }
    
    double fuli(double i,int W,int N,double P)
    {
        double F;
        i=pow(1+i/W,W)-1;
        F=P*pow((i+1),N);
        return F;
    }
    
    double gusuan(double i,int W,int N,double F)
    {
        double P;
        i = pow(1+i/W,W)-1;
        P = F/pow((i+1),N);
        return P;
    }
    double shijian(double P,double i,double F)
    {
        double N,x;
        x=F/P;
        N=(log(x))/(log(i+1));
        return N;
    
    }
    double nianxian(double P,double N,double F)
    {
        double i;
         //i = W*(pow(pow(F/P,1.0/N),1.0/W)-1.0);
         i = pow(F/P,1.0/N)-1.0;
         return i;
    }
    void main()
    {
        double P,F1,F,i; //P是本金,F是收益,i年利率
        int N,W,ch2; //是期限
        while(1)
        {
        printf("		***************欢迎使用复利计算器*************
    
    ");
        printf("		|     -----1:复利---------------    |
    
    ");
        printf("		|     -----2:单利---------------    |
    
    ");
        printf("		|     -----3:估算----------------    |
    
    ");
        printf("		|     -----4:年限----------------    |
    
    ");
        printf("		|     -----5:年利率--------------    |
    
    ");
        printf("		|     -----0:退出----------------    |
    
    ");
        printf("请选择
    ");
        scanf("%d",&ch2);//控制选择
        switch(ch2){
        case 1:
            printf("请输入本金:
    ");
            scanf("%lf",&P);
            printf("请输入年利率
    ");
            scanf("%lf",&i);
            printf("请输入年限:
    ");
            scanf("%d",&N);
            printf("请输入复利次数:
    ");
            scanf("%d",&W);
            F1 = fuli(i,W,N,P); break;
        case 2:
            printf("请输入本金:
    ");
            scanf("%lf",&P);
            printf("请输入年利率
    ");
            scanf("%lf",&i);
            printf("请输入年限:
    ");
            scanf("%d",&N);
            F1 = danli(i,N,P); break;
        case 3:
            printf("请输入本利
    ");
            scanf("%lf",&F);
            printf("请输入年利率
    ");
            scanf("%lf",&i);
            printf("请输入年限:
    ");
            scanf("%d",&N);
            printf("请输入复利次数:
    ");
            scanf("%d",&W);
            F1 = gusuan(i,W,N,F);
            break;
            
        case 4:
            printf("请输入本金
    ");
            scanf("%lf",&P);
            printf("请输入年利率
    ");
            scanf("%lf",&i);
             printf("请输入本利
    ");
            scanf("%lf",&F);
            F1=shijian(P,i,F);
            break;
        case 5:
    
            printf("请输入本金:
    ");
             scanf("%lf",&P);
             printf("请输入本利:
    ");
             scanf("%lf",&F);
             printf("请输入年限
    ");
             scanf("%d",&N);
             
         
            F1=nianxian(P,N,F);
            
            break;
    
        case 0:break;
        }
        if(ch2==0)
            break;
        printf("结果为:%.2lf
    ",F1);
        }
    }

  • 相关阅读:
    android数据恢复
    UVA 690 Pipeline Scheduling
    2017 国庆湖南 Day4
    2017 国庆湖南 Day5
    2017 国庆湖南 Day6
    2017国庆 清北学堂 北京综合强化班 Day1
    2017 国庆湖南Day2
    bzoj 2962 序列操作
    UVA 818 Cutting Chains
    UVA 211 The Domino Effect
  • 原文地址:https://www.cnblogs.com/wangdahua/p/5289152.html
Copyright © 2020-2023  润新知