Advertisement
Spocoman

Cat Food

Sep 2nd, 2024
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double bedPrice = Double.parseDouble(scanner.nextLine()),
  7.                 food, totalFood = 0;
  8.         int catCount = Integer.parseInt(scanner.nextLine()),
  9.                 firstGroup = 0, secondGroup = 0, thirdGroup = 0;
  10.  
  11.         for (int i = 0; i < catCount; i++) {
  12.             food = Double.parseDouble(scanner.nextLine());
  13.             totalFood += food;
  14.             if (food >= 100 && food < 200) {
  15.                 firstGroup++;
  16.             } else if (food >= 200 && food < 300) {
  17.                 secondGroup++;
  18.             } else if (food >= 300 && food < 400) {
  19.                 thirdGroup++;
  20.             }
  21.         }
  22.  
  23.         double priceForFoodPerDay = totalFood * 0.01245;
  24.         System.out.printf("Group 1: %d cats.\n", firstGroup);
  25.         System.out.printf("Group 2: %d cats.\n", secondGroup);
  26.         System.out.printf("Group 3: %d cats.\n", thirdGroup);
  27.         System.out.printf("Price for food per day: %.2f lv.\n", priceForFoodPerDay);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement