• 复利计算3


    #include<stdio.h>
    #include<math.h>

    void fuli()
    {
    int day;
    double total = 1.0f;
    float money;
    float base;
    double total1;
    printf("------------------------------------------------------------ ");
    printf("每年的年利率比为:");
    scanf("%f",&base);
    printf("------------------------------------------------------------ ");
    printf("输入你存入的年数:");
    scanf("%d",&day);
    total=total*pow(1+base,day);
    printf("------------------------------------------------------------- ");
    printf("每年的年利率%f,连续%d年,总受益的利率:%lf ",base,day,total);
    printf("------------------------------------------------------------- ");
    printf("输入本金金额:");
    scanf("%f",&money);
    total1=money*total;
    printf("------------------------------------------------------------- ");
    printf("你将可以得到:%lf ",total1);
    }
    void danli()
    {
    int day;
    double total = 1.0f;
    float money;
    float base;
    double total1;
    printf("------------------------------------------------------------ ");
    printf("每年的年利率比为:");
    scanf("%f",&base);
    printf("------------------------------------------------------------ ");
    printf("输入你存入的年数:");
    scanf("%d",&day);
    total=base*day;
    printf("------------------------------------------------------------- ");
    printf("每年的年利率%f,连续%d年,总受益的利率:%lf ",base,day,total);
    printf("------------------------------------------------------------- ");
    printf("输入本金金额:");
    scanf("%f",&money);
    total1=money+money*total;
    printf("------------------------------------------------------------- ");
    printf("你将可以得到:%lf ",total1);
    }
    void fanxiang()
    {
    float money;
    float base;
    double total = 1.0f;
    int day;
    int x;
    double total1;
    printf("请输入你需要得到的金额: ");
    scanf("%f",&money);
    printf("请输入平均年回报率: ");
    scanf("%f",&base);
    printf("请输入存入的年数 ");
    scanf("%d",&day);
    printf("若是复利选择1,单利选择2 ");
    scanf("%d",&x);
    if(x==1)
    {
    total=total*pow(1+base,day);
    total1=money/total;
    printf("需要的本金为:%f ",total1);
    }
    else
    {
    total=base*day;
    total1=money/(1+total);
    printf("需要的本金为:%f ",total1);
    }
    }
    void gupiao()
    {
    float money;
    double base=0.1;
    float total;
    double day;
    printf("请输入你的本金: ");
    scanf("%f",&total);
    printf("请输入你需要得到的金额: ");
    scanf("%f",&money);
    printf("此股票平均年报酬率为(百分之十)! ");
    day=(money-total)/(total*base);

    printf("需要的年数为:%.3lf年 ",day);

    }

    void ligunli()
    {

    float base;
    int day;
    int x;
    int i;
    double total1;
    double total2;
    double total3=0;

    printf("若是月利选择1,年利选择2 ");
    scanf("%d",&x);
    if(x==1)
    {
    printf("请输入你的本金: ");
    scanf("%lf",&total1);
    printf("请输入平均月回报率: ");
    scanf("%f",&base);
    printf("请输入存入的月数 ");
    scanf("%d",&day);
    for(i=1;i<=day;i++)
    {
    total2=total1+(total1*base);
    total1=total2;
    total3=total1+total3;
    }
    printf("最后可以得到%.3lf元 ",total3);
    }

    else
    {
    printf("请输入你的本金: ");
    scanf("%lf",&total1);
    printf("请输入平均年回报率: ");
    scanf("%f",&base);
    printf("请输入存入的年数 ");
    scanf("%d",&day);
    for(i=1;i<=day;i++)
    {
    total2=total1+(total1*base);
    total1=total2;
    total3=total1+total3;
    }
    printf("最后可以得到%.3lf元 ",total3);
    }
    }
    void touzi()
    {
    float money;
    double base=0.1;
    float total;
    double day;
    printf("请输入你的本金: ");
    scanf("%f",&total);
    printf("请输入你需要得到的金额: ");
    scanf("%f",&money);
    printf("请输入存入的年数: ");
    scanf("%lf",&day);
    base=(money-total)/(day*total);
    printf("投资工具报酬率需要有%.3lf才够 ",base);
    }


    void main()
    {
    int num=4;
    printf(" ");
    printf(" ");
    printf(" ");
    printf(" ");
    printf(" ");
    printf(" ");
    printf(" ------------------------------------- ");
    printf(" 欢迎来到广州商业银行 ");
    printf(" 顾客你可以根据1~3选择 ");
    printf(" 1.复利计算 ");
    printf(" 2.单利计算 ");
    printf(" 3.送你养老金计算方法 ");
    printf(" 4.股票赚钱哟 ");
    printf(" 5.投资工具找的好才赚钱哟 ");
    printf(" 6.本利与本金的存款计算 ");
    printf(" ------------------------------------- ");
    printf(" ");
    printf("请根据数字选择你需要的功能(1~6) ");
    scanf("%d",&num);
    switch(num)
    {
    case 1:
    fuli();
    break;
    case 2:
    danli();
    break;
    case 3:
    fanxiang();
    break;
    case 4:
    gupiao();
    break;
    case 5:
    touzi();
    break;
    case 6:
    ligunli();
    break;
    }
    }

  • 相关阅读:
    重写不受限制
    类的向上转型(安全)向下转型(不安全)
    类的继承之构造函数和析构函数的顺序
    父类和子类的截断现象
    派生类重写方法
    运算符重载总结(大全)
    运算符重载方法3
    运算符重载方法2
    Shell基础编程
    TCP Wrappers(简单防火墙)---限制IP登录ssh
  • 原文地址:https://www.cnblogs.com/huaziyi666/p/5288841.html
Copyright © 2020-2023  润新知