Advertisement
Spocoman

01. Back To The Past

Sep 8th, 2023
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     double money;
  8.     cin >> money;
  9.  
  10.     int year;
  11.     cin >> year;
  12.  
  13.     int ivanchoEge = 18;
  14.  
  15.     for (int i = 1800; i <= year; i++) {
  16.  
  17.         money -= 12000;
  18.  
  19.         if (i % 2 == 1) {
  20.             money -= 50 * ivanchoEge;
  21.         }
  22.         ivanchoEge++;
  23.     }
  24.  
  25.     cout.setf(ios::fixed);
  26.     cout.precision(2);
  27.  
  28.     if (money < 0) {
  29.         cout << "He will need " << abs(money) << " dollars to survive.\n";
  30.     }
  31.     else {
  32.         cout << "Yes! He will live a carefree life and will have " << money << " dollars left.\n";
  33.     }
  34.    
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement