Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.PrintStream;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine()),
- dailyDogFood, dailyCatFood, eatenDogsFood = 0, eatenCatsFood = 0;
- double availableFood = Double.parseDouble(scanner.nextLine()), cookies = 0;
- for (int i = 1; i <= days; i++) {
- dailyDogFood = Integer.parseInt(scanner.nextLine());
- dailyCatFood = Integer.parseInt(scanner.nextLine());
- if (i % 3 == 0) {
- cookies += 0.1 * (dailyDogFood + dailyCatFood);
- }
- eatenDogsFood += dailyDogFood;
- eatenCatsFood += dailyCatFood;
- }
- double totalEatenFood = eatenDogsFood + eatenCatsFood;
- System.out.printf("Total eaten biscuits: %dgr.\n", (int) Math.round(cookies));
- System.out.printf("%.2f%% of the food has been eaten.\n", 100.0 * totalEatenFood / availableFood);
- System.out.printf("%.2f%% eaten from the dog.\n", 100.0 * eatenDogsFood / totalEatenFood);
- System.out.printf("%.2f%% eaten from the cat.\n", 100.0 * eatenCatsFood / totalEatenFood);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement