回 帖 发 新 帖 刷新版面

主题:为什么运行不了,哪出错了?

#include<iostream>
#include<cmath>
int main()
{
 unsigned long loanAmount=150000;
 float annualInterestRate=6.0;
 unsigned short loanLength=30;
 const unsigned short MONTHS_IN_YEAR=12;
 float monthlyInterestRate=annualInterestRate/MONTHS_IN_YEAR;
 monthlyInterestRate=monthlyInterestRate/100;
 unsigned short numberPayments=loanLength*MONTHS_IN_YEAR;
 float monthlyPayment=1-pow((1+monthlyInterestRate),-numberPayments);
 monthlyPayment=monthlyInterestRate/monthPayment;
 monthlyPayment=loanAmount*monthlyPayment;
 std::cout<<"Assuming a loanin the amount of $"<<loanAmount<<",at"<<annualInterestRate
  <<"% interdet,over"<<loanLength<<"yeats,the monthly payment would be $";
 std::cout.setf(std::ios_base::fixed);
 std::cout.setf(std::ios_base::showpoint);
 std::cout.precision(2);
 std::cout<<monthlyPayment<<".\n";
 std::cout<<"press Enter or return to continue";
 std::cin.get();
 return 0;
}
我是刚开始学c++,各位帮我看看哪出问题了,谢谢了

回复列表 (共3个回复)

沙发

我是刚开始学c++,各位帮我看看哪出问题了,谢谢了
------ 你想告诉大家哪里有问题
若是编译不通过,贴出出错行号,以及编译器给出的错误信息
若是运行结果不符合你的预期,给出你的输入,实际输出,已经期望的输出

板凳


嗯 明白了 谢谢指点。我是刚开始学这论坛我也是刚加入很多东西都不明白,还望以后能多多指教。[em2]

3 楼

monthPayment未定义

我来回复

您尚未登录,请登录后再回复。点此登录或注册