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

📄 application2-3.cpp

📁 对于特定长度的高速公路
💻 CPP
字号:
#include <iostream> 
#include <cmath> 
#include <iomanip> 
#include <locale> 
 
using namespace std; 
   
// Compute the initial investment necessary for  
// a specified future value. 
double initval(double targetValue, double rateOfRet, 
               int numYears, int compPerYear) {  
  double b, e;  
 
  rateOfRet /= 100.0; // convert percentage to fraction  
 
  b = (1 + rateOfRet/compPerYear);  
  e = compPerYear * numYears;  
  
  return targetValue / 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 desired future value: "; 
  cin >> p; 
 
  cout << "Enter rate of return: "; 
  cin >> r; 
 
  cout << "Enter number years: "; 
  cin >> y; 
 
  cout << "Enter number of compoundings per year: "; 
  cin >> cpy; 
 
  cout << "\nInitial investment required: "  
       << fixed << setprecision(2) 
       << initval(p, r, y, cpy) << endl; 
 
  return 0; 
}

⌨️ 快捷键说明

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