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

📄 application2-1.cpp

📁 对于特定长度的高速公路
💻 CPP
字号:
#include <iostream> 
#include <cmath> 
#include <iomanip> 
#include <locale> 
 
using namespace std; 
 
// Compute ;the regular payments on a loan. 
double regpay(double principal, double intRate, 
              int numYears, int payPerYear) {  
  double numer;  
  double denom;  
  double b, e;  
  
  intRate /= 100.0; // convert percentage to fraction  
 
  numer = intRate * principal / payPerYear;  
 
  e = -(payPerYear * numYears);  
  b = (intRate / payPerYear) + 1.0;  
  
  denom = 1.0 - pow(b, e);  
  
  return numer / denom;  
}    
 
int main() { 
  double p, r; 
  int y, ppy; 
 
  // Set locale to English.  Adjust as necessary 
  // for your language and/or egion. 
  cout.imbue(locale("english")); 
 
  cout << "Enter principal: "; 
  cin >> p; 
 
  cout << "Enter interest rate (as a percentage): "; 
  cin >> r; 
 
  cout << "Enter number years: "; 
  cin >> y; 
 
  cout << "Enter number of payments per year: "; 
  cin >> ppy; 
 
  cout << "\nPayment: " << fixed << setprecision(2) 
       << regpay(p, r, y, ppy) << endl; 
 
  return 0; 
}

⌨️ 快捷键说明

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