Advertisement
Spocoman

Cat Food

Sep 15th, 2023
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int catCount, firstGroup = 0, secondGroup = 0, thirdGroup = 0;
  8.     cin >> catCount;
  9.  
  10.     double food, totalFood = 0;
  11.  
  12.     for (int i = 0; i < catCount; i++) {
  13.         cin >> food;
  14.         totalFood += food;
  15.  
  16.         if (food >= 100 && food < 200) {
  17.             firstGroup++;
  18.         }
  19.         else if (food >= 200 && food < 300) {
  20.             secondGroup++;
  21.         }
  22.         else if (food >= 300 && food < 400) {
  23.             thirdGroup++;
  24.         }
  25.     }
  26.     double priceForFoodPerDay = totalFood * 0.01245;
  27.    
  28.     cout << "Group 1: " << firstGroup << " cats.\n";
  29.     cout << "Group 2: " << secondGroup << " cats.\n";
  30.     cout << "Group 3: " << thirdGroup << " cats.\n";
  31.     printf("Price for food per day: %.2f lv.\n", priceForFoodPerDay);
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement