csansoon

P2.10 P85370 Interest (1)

Sep 21st, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.     cout.setf(ios::fixed);
  7.     cout.precision(4);
  8.     double c, i, t;
  9.     string o;
  10.     cin >> c >> i >> t >> o;
  11.     if(o == "simple") cout << (c*(1+i*t/100)) << endl;
  12.     else {
  13.         double s = 1;
  14.         for(int n = 0; n < t; n ++) s= s *(1+i/100);
  15.         cout << c*s << endl;
  16.     }
  17. }
Add Comment
Please, Sign In to add comment