Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double bedPrice = Double.parseDouble(scanner.nextLine()),
- food, totalFood = 0;
- int catCount = Integer.parseInt(scanner.nextLine()),
- firstGroup = 0, secondGroup = 0, thirdGroup = 0;
- for (int i = 0; i < catCount; i++) {
- food = Double.parseDouble(scanner.nextLine());
- totalFood += food;
- if (food >= 100 && food < 200) {
- firstGroup++;
- } else if (food >= 200 && food < 300) {
- secondGroup++;
- } else if (food >= 300 && food < 400) {
- thirdGroup++;
- }
- }
- double priceForFoodPerDay = totalFood * 0.01245;
- System.out.printf("Group 1: %d cats.\n", firstGroup);
- System.out.printf("Group 2: %d cats.\n", secondGroup);
- System.out.printf("Group 3: %d cats.\n", thirdGroup);
- System.out.printf("Price for food per day: %.2f lv.\n", priceForFoodPerDay);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement