Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FoodForDogs {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int days = Integer.parseInt(scan.nextLine());
- double kolichestvoHrana = Double.parseDouble(scan.nextLine());
- double dogFood = 0;
- double catFood = 0;
- double obshto = 0;
- double biscuits = 0;
- double obshoDog = 0;
- double obshoCat = 0;
- double obshtoObshto = 0;
- double bisss = 0;
- for (int i = 1; i <= days; i++) {
- dogFood = Double.parseDouble(scan.nextLine());
- catFood = Double.parseDouble(scan.nextLine());
- obshto = dogFood + catFood;
- obshoDog = obshoDog + dogFood;
- obshoCat = obshoCat + catFood;
- obshtoObshto = obshtoObshto + obshto;
- if (i % 3 == 0) {
- biscuits = obshto * 0.1;
- bisss = bisss + biscuits;
- }
- }
- double resultIzqdena = obshtoObshto / kolichestvoHrana * 100;
- double resultDog = obshoDog / obshtoObshto * 100;
- double result = obshoCat / obshtoObshto * 100;
- double biss = Math.abs(bisss);
- System.out.printf("Total eaten biscuits: %.0fgr.", biss);
- System.out.printf("%n%.2f%% of the food has been eaten.", resultIzqdena);
- System.out.printf("%n%.2f%% eaten from the dog.", resultDog);
- System.out.printf("%n%.2f%% eaten from the cat.", result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement