Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 28th, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.OutputStream;
  2. import java.util.Scanner;
  3.  
  4. public class PetFood {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int days = Integer.parseInt(scanner.nextLine());
  8.         int allFood = Integer.parseInt(scanner.nextLine());
  9.         double earn = 0;
  10.          int dogEats =0;
  11.         int catEats = 0;
  12.        int leftFood = allFood;
  13.         for (int i = 1; i <= days ; i++) {
  14.             int dogEat = Integer.parseInt(scanner.nextLine());
  15.             int catEat = Integer.parseInt(scanner.nextLine());
  16.  
  17.             dogEats += dogEat;
  18.             catEats += catEat;
  19.             leftFood -= dogEat;
  20.             leftFood -= catEat;
  21.             if(i == 3){
  22.                 earn = Math.round(  0.10 * (dogEat + catEat));
  23.             }
  24.         }
  25.  
  26.         int allEats = catEats + dogEats;
  27.         double dogPercent = dogEats * 100 / allEats;
  28.         double catPercent = catEats * 100 / allEats;
  29.         System.out.printf("Total eaten biscuits: %.0fgr.%n", earn);
  30.         double percentAllFood = allEats * 100 / allFood;
  31.         System.out.printf("%.2f%% of the food has been eaten.%n",percentAllFood);
  32.         System.out.printf("%.2d%% eaten from the dog.%n",dogPercent);
  33.         System.out.printf("%.2d%% eaten from the cat.",catPercent);
  34.  
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top