Advertisement
v4m4v4

Harvest

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