Advertisement
DidiMilikina

02.Three brothers

Oct 8th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     double first_brother_cleaning;
  9.     double second_brother_cleaning;
  10.     double third_brother_cleaning;
  11.     double father_fisihng;
  12.  
  13.     cin >> first_brother_cleaning >> second_brother_cleaning >> third_brother_cleaning
  14.         >> father_fisihng;
  15.  
  16.     double total_time = 1 / (1 / first_brother_cleaning + 1 / second_brother_cleaning
  17.         + 1 / third_brother_cleaning);
  18.     double time_with_relax = total_time * 1.15;
  19.     double left_hours = father_fisihng - time_with_relax;
  20.    
  21.     cout << "Cleaning time: " << fixed << setprecision(2) << time_with_relax << endl;
  22.  
  23.     if (time_with_relax < father_fisihng)
  24.     {
  25.         cout << "Yes, there is a surprise - time left -> " << fixed << setprecision(0)
  26.         <<floor(left_hours) << " hours." << endl;
  27.     }
  28.     else
  29.     {
  30.         cout << "No, there isn't a surprise - shortage of time -> "
  31.         << fixed << setprecision(0) << ceil(abs(left_hours)) <<" hours." << endl;
  32.     }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement