Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examPreparation;
- import java.util.Scanner;
- public class FoodForPets {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int daysCount = Integer.parseInt(scanner.nextLine());
- double foodQuantity = Double.parseDouble(scanner.nextLine());
- double totalCountBiscuits = 0.0;
- double allEatenFood = 0.0;
- double dogEatenFood = 0.0;
- double catEatenFood = 0.0;
- for (int i = 1; i <= daysCount; i++) {
- int dogFood = Integer.parseInt(scanner.nextLine());
- int catFood = Integer.parseInt(scanner.nextLine());
- dogEatenFood += dogFood;
- catEatenFood += catFood;
- double biscuits = 0.0;
- int dailyFood = dogFood + catFood;
- allEatenFood += dailyFood;
- if (i % 3 == 0) {
- biscuits = dailyFood * 0.10;
- totalCountBiscuits += biscuits;
- }
- }
- //• "{процент изядена храна от кучето}% eaten from the dog."
- //• "{процент изядена храна от котката}% eaten from the cat."
- System.out.printf("Total eaten biscuits: %.0fgr.%n", totalCountBiscuits);
- System.out.printf("%.2f%% of the food has been eaten.%n", allEatenFood / foodQuantity * 100);
- System.out.printf("%.2f%% eaten from the dog.%n", dogEatenFood / allEatenFood * 100);
- System.out.printf("%.2f%% eaten from the cat.", catEatenFood / allEatenFood * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement