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

📄 a205depo.cpp

📁 esempi vari per c++(schemi base)
💻 CPP
字号:
// nuovi elementi: iomanip, setw, setprecision, setf, ::
#include <iostream>
#include <iomanip>  // permette di usare setw, setprecision e setf
		      
using namespace std;

int main() {
int anni, contanni;
float npercento, euro, interesse_corrente_anno, interesse_totale;

cout << "                     Calcolo dell'interesse accumulato\n";
cout << "                     ---------------------------------\n";
cout << "Introdurre la durata del deposito in anni (max 30), la cifra "
     << "depositata\n";
cout << "in euro e il tasso di interesse\n";
cin >> anni >> euro >> npercento;
cout << endl << endl;
if (anni<=0 || anni>30 || euro<=0 || npercento<=0) {
   cout << " dati forniti:  anni == " << anni
	<< ",  euro == " << euro
	<< ",  npercento == " << npercento
	<< "\n dati non validi  -  programma interrotto.\n";
   }
else {
   cout << "   introiti su un deposito di                  "
	<< setw(8) << euro
	<< " euro\n"
	<< "   tenuto per                                  "
	<< setw(8) << anni
	<< " anni\n"
	<< "   ad un interesse annuale composto del        "
	<< setw(8) << npercento
	<< " percento\n"
	<< " -----------------------------------------------------------------\n"
	<< "      numero       interesse       capitale      interesse\n"
	<< "       anno         annuale                      accumulato\n"
	<< " -----------------------------------------------------------------\n";
//   cout.setf(ios::showpoint);
   cout.setf(ios::fixed, ios::floatfield);
   for (contanni=1, interesse_totale=0; contanni<=anni; contanni++) {
      interesse_corrente_anno = (euro * npercento) / 100;
      interesse_totale += interesse_corrente_anno;
      euro += interesse_corrente_anno;
      cout << setprecision(3);
      cout << setw(10) << contanni;
      cout << setw(18) << interesse_corrente_anno;
      cout << setw(16) << euro;
      cout << setw(14) << interesse_totale << endl;
      }
   cout << " -----------------------------------------------------------------\n";
   }
return 0;
}

⌨️ 快捷键说明

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