Advertisement
DidiMilikina

02. Harvest

Oct 7th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     double vineyard, grapes, need_wine, workers;
  8.     cin >> vineyard >> grapes >> need_wine >> workers;
  9.  
  10.     double total_grapes = vineyard * grapes;
  11.     double wine = 0.4 * total_grapes / 2.5;
  12.     double total_wine = wine - need_wine;
  13.     double results = total_wine / workers;
  14.  
  15.     if (wine >= need_wine)
  16.     {
  17.         int floor_wine = floor(wine);
  18.         int ceild_total_wine = ceil(total_wine);
  19.         int ceild_results = ceil(results);
  20.         cout << "Good harvest this year! Total wine: " << floor_wine << " liters." << endl;
  21.         cout << ceild_total_wine << " liters left -> " << ceild_results << " liters per person." << endl;
  22.     }
  23.     else
  24.     {
  25.         int floor_total_wine = abs(total_wine);
  26.         total_wine = abs(total_wine);
  27.         cout << "It will be a tough winter! More "
  28.             << floor_total_wine << " liters wine needed." << endl;
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement