年金计划的问题:论据太少

发布于 2024-11-17 06:48:58 字数 497 浏览 0 评论 0原文

我正在编写一个程序来计算出年金的数学方程。公式如图 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 shown
A = 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

<逆流佳人身旁 2024-11-24 06:48:58
cout<<(M * ( pow ((( 1 + r ), n ) - 1 )/(r * ((pow(1 + r), n)))));

您只向外部pow 调用传递一个参数。第二个参数在哪里?

你为什么不简单点呢?为什么你把它弄得如此难以阅读,以至于连你都无法正确阅读和理解它?如果你自己都无法理解,别人怎么会理解呢?

也许你想这样做:

double r1 = pow (1 + r,n-1 );
double r2 = pow (1 + r,n)
double A =  M * r1/ (r * r2);
cout<< A;

根据我能理解的,我写了这个。正确吗?如果您想要稍微不同的计算,请执行类似的操作。 但必须通过简单步骤来完成。这对您以及那些将阅读您的代码的人都有好处。

cout<<(M * ( pow ((( 1 + r ), n ) - 1 )/(r * ((pow(1 + r), n)))));

You're passing just one argument to the outerpow 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:

double r1 = pow (1 + r,n-1 );
double r2 = pow (1 + r,n)
double A =  M * r1/ (r * r2);
cout<< A;

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文