⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 application2-2.cpp

📁 对于特定长度的高速公路
💻 CPP
字号:
#include <iostream> 
#include <cmath> 
#include <iomanip> 
#include <locale> 
 
using namespace std; 
   
// Compute the future value of an investment.  
double futval(double principal, double rateOfRet, 
              int numYears, int compPerYear) {  
  double b, e; 
  
  rateOfRet /= 100.0; // convert percentage to fraction  
 
  b = (1 + rateOfRet/compPerYear); 
  e = compPerYear * numYears; 
  
  return principal * pow(b, e); 
} 
 
int main() { 
  double p, r; 
  int y, cpy; 
 
  // Set locale to English.  Adjust as necessary 
  // for your language and/or egion. 
  cout.imbue(locale("english")); 
 
  cout << "Enter principal: "; 
  cin >> p; 
 
  cout << "Enter rate of return (as a percentage): "; 
  cin >> r; 
 
  cout << "Enter number years: "; 
  cin >> y; 
 
  cout << "Enter number of compoundings per year: "; 
  cin >> cpy; 
 
  cout << "\nFuture value: " << fixed << setprecision(2) 
       << futval(p, r, y, cpy) << endl; 
 
  return 0; 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -