年金计划的问题:论据太少
我正在编写一个程序来计算出年金的数学方程。公式如图 A = M=[(1+r)^n-1/r(1+r)^n]
。 我使用的程序编译器是 Devcpp,它与我的其他程序一起工作,但我找不到这个错误。它告诉我公式中的参数太少了。
非常感谢任何帮助:)
代码是:
double M, r, n;
cout<<"M = ";
cin>>M;
cout<<"r = ";
cin>>r;
cout<<"n = ";
cin>>n;
cout<<endl;
cout<<"A = M=[(1+r)^n-1/r(1+r)^n]";
cout<<endl<<endl;
cout<<"A = ";
cout<<(M * ( pow ((( 1 + r ), n ) - 1 )/(r * ((pow(1 + r), n)))));
I'm writing a program to work out a math equation to find annuity. the formula is as shownA = M=[(1+r)^n-1/r(1+r)^n]
.
The program compiler I am using is Devcpp it its worked with my other programs and i cannot find the error in this one. it tells me that there are too few arguments in the line with the formula.
any help is greatly appreciated :)
the code is:
double M, r, n;
cout<<"M = ";
cin>>M;
cout<<"r = ";
cin>>r;
cout<<"n = ";
cin>>n;
cout<<endl;
cout<<"A = M=[(1+r)^n-1/r(1+r)^n]";
cout<<endl<<endl;
cout<<"A = ";
cout<<(M * ( pow ((( 1 + r ), n ) - 1 )/(r * ((pow(1 + r), n)))));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只向外部
pow
调用传递一个参数。第二个参数在哪里?你为什么不简单点呢?为什么你把它弄得如此难以阅读,以至于连你都无法正确阅读和理解它?如果你自己都无法理解,别人怎么会理解呢?
也许你想这样做:
根据我能理解的,我写了这个。正确吗?如果您想要稍微不同的计算,请执行类似的操作。 但必须通过简单步骤来完成。这对您以及那些将阅读您的代码的人都有好处。
You're passing just one argument to the outer
pow
call. Where is the second argument?Why don't you simply it? Why did you make it so unreadable that even you cannot read and understand it properly? If you can't understand it yourself, how will others understand it?
Probably you want to do this:
Based on what I could understand, I wrote this. Is it correct? Do it similarly if you wanted slightly different calculation. But must do it in simple steps. That is good for you as well as for those who will read your code.