Advertisement
JosepRivaille

P66529: Interessos (2) v1

Feb 21st, 2015
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. //Programa usant una variable c;
  5.  
  6. int main() {
  7.     cout.setf(ios::fixed);
  8.     cout.precision(4);
  9.     double i, c, aux;
  10.     string t;
  11.     cin >> i >> t;
  12.     c = aux = 1000;
  13.     if (t == "setmanal") {
  14.         i = i/52;
  15.         for (int j = 52; j != 0; --j) {
  16.         c = c + c*(i/100);
  17.         }
  18.     }else if (t == "mensual") {
  19.         i = i/12;
  20.         for (int j = 12; j != 0; --j) {
  21.         c = c + c*(i/100);
  22.         }
  23.     }else if (t == "trimestral") {
  24.         i = i/4;
  25.         for (int j = 4; j != 0; --j) {
  26.         c = c + c*(i/100);
  27.         }
  28.     }else if (t == "semestral") {
  29.         i = i/2;
  30.         for (int j = 2; j != 0; --j) {
  31.         c = c + c*(i/100);
  32.         }
  33.     }
  34.     cout << 100*(c-aux)/aux << endl;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement