Advertisement
Spocoman

03. Harvest

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