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

    #include<stdio.h>
    #include<math.h>
    int year,n;
    double p,q,F=0.0;
    void innit()
    {
    printf("注释:p为现金 ");
    printf(" year为年限 ");
    printf(" n为年复利次数 ");
    printf(" q为年利率 ");
    printf(" F为年复利终值 ");
    }
    void menu()
    {
    printf(" |------------------------------------| ");
    printf(" | welcome | ");
    printf(" |------------------------------------| ");
    printf(" | 1、复利计算 | ");
    printf(" | 2、单利计算 | ");
    printf(" | 0、退出系统 | ");
    printf(" |------------------------------------| ");
    }
    void compoundinterest(){
    int I;
    int ch;
    B:printf(" 1、获取复利终值 ");
    printf(" 2、根据复利终值获取本金 ");
    printf("请选择功能:");
    scanf("%d",&I);
    if(I==1)
    {
    printf("请输入存款金额:");
    scanf("%lf",&p);
    printf("请输入存入存蓄年限:");
    scanf("%d",&year);
    printf("请输入年复利次数:");
    scanf("%d",&n);
    printf("请输入年利率:");
    scanf("%lf",&q);
    F=p*pow((1+q/n),year*n);
    printf("复利终值为%lf:",F);
    }
    if(I==2)
    {
    printf("请输入复利终值:");
    scanf("%lf",&p);
    printf("请输入存入存蓄年限:");
    scanf("%d",&year);
    printf("请输入年复利次数:");
    scanf("%d",&n);
    printf("请输入年利率:");
    scanf("%lf",&q);
    p=F/(pow((1+q/n),year*n));
    printf("复利终值为%lf:",F);
    }
    printf(" 是否要重新计算?(1/0) ");
    scanf("%d",&ch);
    if(ch==1)
    {
    goto B;
    }
    }
    void simpleinterest()
    {
    int n;
    int ch;
    A:printf(" 1、获取单利终值 ");
    printf(" 2、根据单利终值获取本金 ");
    printf("请选择功能:");
    scanf("%d",&n);
    if(n==1)
    {

    printf("请输入存款金额:");
    scanf("%lf",&p);
    printf("请输入存入存蓄年限:");
    scanf("%d",&year);
    printf("请输入年利率:");
    scanf("%lf",&q);

    F=p*(1+q*year);
    printf("单利终值为%lf :",F);}
    if(n==2)
    {
    printf("请输入单复利终值:");
    scanf("%lf",&F);
    printf("请输入存入存蓄年限:");
    scanf("%d",&year);
    printf("请输入年利率:");
    scanf("%lf",&q);

    p=F/(1+q*year);
    printf("本金为%lf :",p);}
    printf(" 是否要重新计算?(1/0) ");
    scanf("%d",&ch);
    if(ch==1)
    {
    goto A;
    }}

    main(){
    int ch,n;
    while(1){
    if(n==0) break;
    innit();
    menu();
    printf("please chose:");
    scanf("%d",&ch);
    switch(ch){
    case 1:compoundinterest();break;
    case 2:simpleinterest();break;
    case 0:n=0;break;
    }}}

  • 相关阅读:
    著名的二分查找的BUG
    C/C++ static用法
    浅谈C++虚函数
    git备忘(长久更新)
    【经典问题】最大子串和
    水波纹效果
    博客迁址 xpeng.scorpionstudio.com
    终于,我们的新产品Fotor Slideshow Maker上线了!!
    分享一款浏览器扩展--美图搜索-图片搜索工具
    分享网页微信防撤回插件
  • 原文地址:https://www.cnblogs.com/4249ken/p/5264418.html
Copyright © 2011-2022 走看看