• 0321 复利计算—贷款


    #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 daikuan()
    {
    int day;
    float money;
    float base;
    double total;
    double total1;
    double total2;
    printf("------------------------------------------------------------ ");
    printf("每年的年利率比为:");
    scanf("%f",&base);
    printf("------------------------------------------------------------ ");
    printf("输入你存入的年数:");
    scanf("%d",&day);
    printf("------------------------------------------------------------- ");
    printf("借款本金金额:");
    scanf("%f",&money);
    base=base/12;
    day=day*12;
    total1=(money*base*pow(1+base,day));
    total2=(pow(1+base,day)-1);
    total=total1/total2;
    printf("------------------------------------------------------------- ");
    printf("你需要每个月还%lf元 ",total);
    }
    void fanxiang()
    {
    float money;
    float base;
    double total = 1.0f;
    int day;
    int x;
    char lab;
    double total1;
    printf("------------------------------------------------------------ ");
    printf("请输入你需要得到的金额: ");
    scanf("%f",&money);
    printf("------------------------------------------------------------ ");
    printf("请输入平均年回报率: ");
    scanf("%f",&base);
    printf("------------------------------------------------------------ ");
    printf("请输入存入的年数 ");
    scanf("%d",&day);
    printf("------------------------------------------------------------ ");
    lab:printf("若是复利选择1,单利选择2 ");
    scanf("%d",&x);
    if(x==1)
    {
    total=total*pow(1+base,day);
    total1=money/total;
    printf("需要的本金为:%f ",total1);
    }
    else if(x==2)
    {
    total=base*day;
    total1=money/(1+total);
    printf("需要的本金为:%f ",total1);
    }
    else
    {
    printf("请重新输入1或者2 ");
    goto lab;
    }

    }
    void gupiao()
    {
    float money;
    double base=0.1;
    float total;
    double day;
    printf("------------------------------------------------------------ ");
    printf("请输入你的本金: ");
    scanf("%f",&total);
    printf("------------------------------------------------------------ ");
    printf("请输入你需要得到的金额: ");
    scanf("%f",&money);
    printf("------------------------------------------------------------ ");
    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("------------------------------------------------------------ ");
    printf("若是月利选择1,年利选择2 ");
    scanf("%d",&x);
    if(x==1)
    {
    printf("------------------------------------------------------------ ");
    printf("请输入你的本金: ");
    scanf("%lf",&total1);
    printf("------------------------------------------------------------ ");
    printf("请输入平均月回报率: ");
    scanf("%f",&base);
    printf("------------------------------------------------------------ ");
    printf("请输入存入的月数 ");
    scanf("%d",&day);
    for(i=1;i<=day;i++)
    {
    total2=total1+(total1*base);
    total1=total2;
    total3=total1+total3;
    }
    printf("最后可以得到%.3lf元 ",total3);
    }

    else if(x==2)
    {
    printf("------------------------------------------------------------ ");
    printf("请输入你的本金: ");
    scanf("%lf",&total1);
    printf("------------------------------------------------------------ ");
    printf("请输入平均年回报率: ");
    scanf("%f",&base);
    printf("------------------------------------------------------------ ");
    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("------------------------------------------------------------ ");
    printf("请输入你的本金: ");
    scanf("%f",&total);
    printf("------------------------------------------------------------ ");
    printf("请输入你需要得到的金额: ");
    scanf("%f",&money);
    printf("------------------------------------------------------------ ");
    printf("请输入存入的年数: ");
    scanf("%lf",&day);
    base=(money-total)/(day*total);
    printf("投资工具报酬率需要有%.3lf才够 ",base);
    }


    void main()
    { while(1){
    int num=7;
    printf(" ");
    printf(" ");
    printf(" ");
    printf(" ");
    printf(" ");
    printf(" ");
    printf(" ------------------------------------- ");
    printf(" 欢迎来到广州商业银行 ");
    printf(" 顾客你可以根据1~7选择 ");
    printf(" 1.复利计算 ");
    printf(" 2.单利计算 ");
    printf(" 3.送你养老金计算方法 ");
    printf(" 4.股票赚钱哟 ");
    printf(" 5.投资工具找的好才赚钱哟 ");
    printf(" 6.本利与本金的存款计算 ");
    printf(" 7.贷款 ");
    printf(" ------------------------------------- ");
    printf(" ");
    printf("请根据数字选择你需要的功能(1~7) ");

    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;
    case 7:
    daikuan();
    break;
    }
    }
    }

    此次增加了贷款功能,增加了可以任意计算的功能

  • 相关阅读:
    Ext.Net多表头跨行跨列
    操作文件
    HighMaps
    HighCharts动态读取显示
    SAP CRM 项目笔记(一) SOW(工作说明书)讨论
    .net 动态编译解决考勤计算问题
    CPU的大小端模式
    将一个数转化为任意进制的数
    关于内存对齐
    常量指针与指针常量
  • 原文地址:https://www.cnblogs.com/huaziyi666/p/5302905.html
Copyright © 2020-2023  润新知