Advertisement
Spocoman

06. Pets

Sep 4th, 2023 (edited)
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int days;
  8.     cin >> days;
  9.  
  10.     double availableFoodInKg, dogFoodPerDayInKg, catFoodPerDayInKg, turtleFoodPerDayInGrams;
  11.     cin >> availableFoodInKg >> dogFoodPerDayInKg >> catFoodPerDayInKg >> turtleFoodPerDayInGrams;
  12.  
  13.     availableFoodInKg -= (dogFoodPerDayInKg + catFoodPerDayInKg + turtleFoodPerDayInGrams / 1000) * days;
  14.  
  15.     if (availableFoodInKg >= 0) {
  16.         cout << floor(availableFoodInKg) << " kilos of food left." << endl;
  17.     }
  18.     else {
  19.         cout << ceil(abs(availableFoodInKg)) << " more kilos of food are needed." << endl;
  20.     }
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement