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

📄 fig05_06.cpp

📁 how to program的书籍源码
💻 CPP
字号:
//Fig.5.6:fig05_06.cpp
//Compound interest calculations with for.
#include<iostream>
using std::cout;
using std::endl;
using std::fixed;

#include<iomanip>
using std::setw;
using std::setprecision;

#include<cmath>
//using std::pow;

int main()
{
	double amount;
	double principal=1000.0;
	double rate=.05;

	cout<<"Year"<<setw(21)<<"Amount on deposit"<<endl;

	cout<<fixed<<setprecision(2);
    rate+=1;
	for(int year=1;year<=10;year++)
	{
		amount=principal*pow(rate,year);

		cout<<setw(4)<<year<<setw(21)<<amount<<endl;
	}
	return 0;
}

⌨️ 快捷键说明

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