Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FoodForPets_04 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int days = Integer.parseInt(scanner.nextLine());
  8. double obshtoKolicestvoXrana = Double.parseDouble(scanner.nextLine());
  9.  
  10. double sumNaDog = 0;
  11. double sumNaCat = 0;
  12. double sumBiscuits = 0;
  13. for (int i = 1; i <= days ; i++) {
  14. int kolicestwoXranaNaKutceto = Integer.parseInt(scanner.nextLine());
  15. int kolicestwoXranaNaKotkata = Integer.parseInt(scanner.nextLine());
  16.  
  17. if(i % 3 == 0){
  18. double biskwitki = (kolicestwoXranaNaKotkata + kolicestwoXranaNaKutceto) * 0.1;
  19. sumBiscuits += biskwitki;
  20. }
  21. sumNaDog += kolicestwoXranaNaKutceto;
  22. sumNaCat += kolicestwoXranaNaKotkata;
  23. }
  24. double sum = Math.round(sumBiscuits);
  25. double eatenFood = sumNaCat + sumNaDog;
  26. double persentOfEatenFood = (eatenFood / obshtoKolicestvoXrana) * 100;
  27. double persentOfDog = (sumNaDog / eatenFood) * 100;
  28. double persentOfCat = (sumNaCat / eatenFood) * 100;
  29. System.out.printf("Total eaten biscuits: %.0fgr.%n", sum);
  30. System.out.printf("%.2f%% of the food has been eaten.%n", persentOfEatenFood);
  31. System.out.printf("%.2f%% eaten from the dog.%n", persentOfDog);
  32. System.out.printf("%.2f%% eaten from the cat.%n", persentOfCat);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement