Advertisement
JosepRivaille

P66529: Interessos (2) v2 (definitiu)

Feb 25th, 2015
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. //Pre: interés en tan per cent i períodes
  5. //Post: TAE corresponent
  6.  
  7. int main() {
  8.     cout.setf(ios::fixed);
  9.     cout.precision (4);
  10.     double i, TAE, p;
  11.     string t;
  12.     cin >> i >> t;
  13.     if (t == "setmanal") p = 52;
  14.     else if (t == "mensual") p = 12;
  15.     else if (t == "trimestral") p = 4;
  16.     else if (t == "semestral") p = 2;
  17.     i = i/100;
  18.     i = i/p;
  19.     TAE = 1+i;
  20.     while (p != 1) {
  21.         TAE = TAE*(1+i);
  22.         --p;
  23.     }
  24.     cout << 100*(TAE-1) << endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement