mfp吧 关注:778贴子:4,973
  • 14回复贴,共1

复利计算。

只看楼主收藏回复

help
@language:simplified_chinese
计算复利。
OK
@end
endh
function fulijs( )
variable x=input("请输入,[本金,利率%,时间]:")
variable a=x[0]
variable b=x[1]
variable c=x[2]
variable d
d=a*((1+b%)**c)
print("结果:"+round(d,3)+"\n")
return (fulijs())
endf


来自Android客户端1楼2016-08-09 11:29回复
    利息d=a*(((1+b%)**c)-1)。弄个if分支,给束循环。把结果汇总作个图


    来自Android客户端2楼2016-08-09 12:08
    回复
      function pic_lix()
      plot2DEX("利息/本金", "(利率(0.04~0.05);时间:50)", "x(本金:元)", "y(利息:元)", "black", true, "4%", "yellow", "point", 4, "blue", "solid", 2, 1, 50, 1, "t", "t*(1.04**50-1)","5%", "yellow", "point", 4, "green", "solid", 2, 1, 50, 1, "t", "t*(1.05**50-1)")
      plot2DEX("利息/时间", "(本金:100;时间:50)", "x(时间:年)", "y(利息:元)", "black", true, "4%", "yellow", "point", 4, "blue", "solid", 2, 1, 50, 1, "t", "100*(1.04**t-1)","5%", "yellow", "point", 4, "green", "solid", 2, 1, 50, 1, "t", "100*(1.05**t-1)")
      plot2DEX("利息/利率", "(本金:100;时间:50)", "x(利率:%)", "y(利息:元)", "black", true, "t%", "yellow", "point", 4, "blue", "solid", 2, 0, 10, 1, "t", "100*((1+t/100)**50-1)")
      endf


      来自Android客户端3楼2016-08-09 14:11
      收起回复


        来自Android客户端4楼2016-08-09 15:10
        回复
          @zhengtao94364 为什么不能把用户输入的数据带到plot2dex里呢?
          function fulijs_tu( )
          //计算第n年的利息。
          variable x=input("请输入,[本金,利率%,时间]:")
          variable a=x[0]
          variable b=x[1]
          variable c=x[2]
          variable d,e
          for e=1 to c step 1
          d=a*(((1+b%)**e)-1)
          print("第"+e+"年的利息:"+round(d,3)+"\n")
          next
          plot2DEX("复利计算", "每年的利息", "x(时间)", "y(利息:元)", "black", true, "增长趋势", "yellow", "point", 4, "blue", "solid", 2, 0, 10, 1, "t", "x[0]*((1+x[1]/100)**x[2]-1)")
          return (fulijs())
          endf
          比如把a,b,c,带进去。我用x[0],x[1],x[2],也不行。


          来自Android客户端5楼2016-08-09 15:28
          回复
            就像这样,为什么是无效的表达式和没有找到定义的参数。
            function fulijs_tu( )
            //计算第n年的利息。
            variable x=input("请输入,[本金,利率%,时间]:")
            variable a=x[0]
            variable b=x[1]
            variable c=x[2]
            plot2DEX("复利计算", "每年的利息", "x(时间)", "y(利息:元)", "black", true, "增长趋势", "yellow", "point", 4, "blue", "solid", 2, 0, c, 1, "t+1", "a*((1+b/100)**(t+1)-1)")
            variable d,e
            for e=1 to c step 1
            d=a*(((1+b%)**e)-1)
            print("第"+e+"年的利息:"+round(d,3)+"\n")
            next
            return (fulijs())
            endf


            来自Android客户端6楼2016-08-09 15:36
            回复
              "a*((1+b/100)**(t+1)-1)"不存在,自变量为t,函数中不能有别的变量,只能是含t的函数f(t)表达式,画图中a,b,c要为常数或含t的表达式


              来自Android客户端7楼2016-08-09 21:41
              收起回复
                function fulijs(a,b,c)
                variable d=a*(((1+b/100)**(c+1))-1)
                variable s="增长趋势,0,"+c+",1,t+1,"+a+"*(((1+"+b/100+")**(t+1))-1)"
                variable s1=tostring(s)
                variable cv1=split(s1,",")
                variable m1=trim(cv1[0])
                variable a1=evaluate(cv1[1])
                variable b1=evaluate(cv1[2])
                variable c1=evaluate(cv1[3])
                variable t1=trim(cv1[4])
                variable f1=trim(cv1[5])
                plot2DEX("复利计算/每年的利息", "每年的利息", "x时间:年", "y利息:元", "black", true,m1, "green", "triangle", 2, "blue", "solid", 1, a1,b1,c1,t1,f1)
                return("利息(元):"+round(d,2))
                endf


                来自Android客户端8楼2016-08-12 12:41
                收起回复
                  成了,现在既可以打出每年的利息,还可以作图。
                  源代码如下:
                  nction fulijs_tu( )
                  //计算第n年的利息。
                  variable x=input("请输入,[本金,利率%,时间]:")
                  variable a=x[0]
                  variable b=x[1]
                  variable c=x[2]
                  variable d,e
                  for e=1 to c step 1
                  d=a*(((1+b%)**e)-1)
                  print("第"+e+"年的利息:"+round(d,3)+"\n")
                  next
                  variable s="增长趋势,-1,"+(c-1)+",1,t+1,"+a+"*(((1+"+b/100+")**(t+1))-1)"
                  variable s1=tostring(s)
                  variable cv1=split(s1,",")
                  variable m1=trim(cv1[0])
                  variable a1=evaluate(cv1[1])
                  variable b1=evaluate(cv1[2])
                  variable c1=evaluate(cv1[3])
                  variable t1=trim(cv1[4])
                  variable f1=trim(cv1[5])
                  plot2DEX("复利计算/每年的利息", "每年的利息", "x时间:年", "y利息:元", "black", true,m1, "green", "triangle", 2, "blue", "solid", 1, a1,b1,c1,t1,f1)
                  return (fulijs_tu())
                  endf
                  感谢@zhengtao94364 的作图函数的完善。


                  来自Android客户端9楼2016-08-12 16:09
                  回复
                    ①循环退出问题,
                    ②输入if(or(a==0,b==0,c==0))即a,b,c有其一为零怎样解决?
                    ③读取文本data进行批量计算并存储。
                    ④相关数据批量作图


                    来自Android客户端11楼2016-08-12 18:39
                    收起回复