zoukankan      html  css  js  c++  java
  • 复利计算

     1 #include<stdio.h>
     2 
     3 #include<math.h>
     4 //复利
     5 void fuli(){
     6     int n,k;
     7     double F,P;
     8     float i;
     9     printf("请输入所存入的本金:");
    10     scanf("%lf",&P);
    11     printf("请输入所存的年利率比:");
    12     scanf("%f",&i);
    13     printf("请输入所存的年限:");
    14     scanf("%d",&n);
    15     printf("请输入所存的复利次数:");
    16     scanf("%d",&k);
    17     F=P*pow(i/k+1,k*n);
    18     printf("
    总金额为:%.4lf
    
    ",F);
    19  
    20 }
    21 //单利
    22 void danli()
    23 {
    24     int n,k;
    25     double F,P;
    26     float i;
    27     printf("请输入所存入的本金:");
    28     scanf("%lf",&P);
    29     printf("请输入所存的年利率比:");
    30     scanf("%f",&i);
    31     printf("请输入所存的年限:");
    32     scanf("%d",&n);
    33     printf("请输入所存的复利次数:");
    34     scanf("%d",&k);
    35     F=P*(1+i*n);
    36     printf("
    总金额为:%.4lf
    
    ",F);
    37 }
    38 //本金
    39 void benjin()
    40 {
    41     int n,k;
    42     double F,P;
    43     float i;
    44     printf("请输入总金额:");
    45     scanf("%lf",&F);
    46     printf("请输入所存的年利率比:");
    47     scanf("%f",&i);
    48     printf("请输入所存的年限:");
    49     scanf("%d",&n);
    50     printf("请输入所存的复利次数:");
    51     scanf("%d",&k);
    52     P=F/pow(i/k+1,k*n);
    53     printf("
    本金为:%.4lf
    
    ",P);
    54  
    55 }
    56  
    57 void main(){
    58     int a;
    59     printf("1、复利计算");
    60     printf("
    2、单利计算");
    61     printf("
    3、本金计算");
    62     printf("
    请输入你的选择:");
    63     scanf("%d",&a);
    64     if(a==1)
    65         fuli();
    66     else if(a==2)
    67         danli();
    68     else if(a==3)
    69         benjin();
    70 }
  • 相关阅读:
    Cefsharp支持MP4和MP3的CEF库cef.redist.x86.3.2623,对应Cefsharp49
    解读设计模式
    模拟支付宝、淘宝登录2
    模拟支付宝、淘宝登录1
    上一篇随笔是2011-11-21 17:23,唏嘘啊。。。
    像素格式
    YUV格式详解
    认识RGB和YUV
    WPF性能优化经验总结
    【日期正则表达式】
  • 原文地址:https://www.cnblogs.com/B5002/p/5309670.html
Copyright © 2011-2022 走看看