Advertisement
westron

finance (cout cin)

Apr 8th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. using namespace std;
  4.  
  5. void main()
  6. {
  7.     float x, y, p, year = 0;
  8.     cout << "input x p y = ";
  9.     cin >> x >> p >> y;
  10.     while (x < y)
  11.     {
  12.         year++;
  13.         x += x / 100 * p;
  14.         x = nearbyint(x * 100) / 100;
  15.     }
  16.     cout << "the result is " << year << "\n\n";
  17.     system("pause");
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement