gpt4 book ai didi

c++ - 在表达式中使用 pow 函数

转载 作者:太空宇宙 更新时间:2023-11-04 16:22:41 33 4
gpt4 key购买 nike

<分区>

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>

// Defining Variable

using namespace std;

const int MONTHS_IN_YEAR = 12;
const int PURCHASE_PRICE= 123500;
const int AMOUNT_MORG= 111150;
const int DOWN_PAYMENT = 12350;
const float MONTHLY_RATE= 0.542f;
const float FORMULA_RATE=1.542f;
float PAYMENT;
int main()




{

PAYMENT= (float)(MONTHLY_RATE*AMOUNT_MORG)*(pow(1.542,180));
cout << PAYMENT;

cout << fixed << showpoint << setprecision(2);


system ("cls");
cout <<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$";
cout <<'$';
cout << setw(79)<<'$';
cout<<'$';
cout << setw(79)<<'$';
cout << '$';
cout << setw(79)<<'$';
cout << '$'<<" " <<"Welcome to the mortgage information calculator 2013"
<<" " << '$';
cout <<'$';
cout << setw(79)<<'$';
cout<<'$';
cout << setw(79)<<'$';
cout <<'$'<< " "<< " Made exclusively for Dewey,Cheatum and Howe bankers"
<<" "<<'$';
cout <<'$';
cout << setw(79)<<'$';
cout<<'$'<<" "<< "by: Steven Fisher"
<<" "<<'$';
cout <<'$';
cout << setw(79)<<'$';
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;

system ("pause");




return 0;

}

这是我的代码。我是 C++ 语言的新手,类里面分配了一个项目,我必须计算房屋抵押贷款的每月还款额。

我需要使用 pow 函数并将幂乘以一个表达式。这是我尝试过的:

(float)(MONTHLY_RATE*AMOUNT_MORG)*(pow(1.542,180))

当我运行程序时,我得到了 1.#inf 的答案。

如有任何帮助,我们将不胜感激。

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com