Advertisement
Filip13

maline

Oct 21st, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int years;
  7. double tones, percentage, first_year;
  8.  
  9. cin >> years >> first_year >> percentage;
  10. int current_year = 1;
  11.  
  12. if (years > 0) {
  13. tones = first_year;
  14. }
  15. else {
  16. tones = 0;
  17. }
  18.  
  19. while (current_year < years) {
  20.  
  21. tones = tones + tones * percentage / 100.0;
  22. current_year++;
  23. }
  24.  
  25.  
  26. cout << int(tones * 100) / 100.0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement