G2A Many GEOs
SHARE
TWEET

Untitled

a guest Mar 29th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package javaapplication6;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class CareOfPuppy02 {
  6.  
  7.     private static int i;
  8.  
  9.     public static void main(String[] args) {
  10.         Scanner scanner = new Scanner(System.in);
  11.         int days = Integer.parseInt(scanner.nextLine());
  12.         Double food = Double.parseDouble(scanner.nextLine());
  13.         double FoodEatenDog, FoodEatenCat, totalEatenFood, biscuits = 0;
  14.         Double PercentageTotalEatenFood = null, PercentageTotalFoodEatenDog = null, PercentageTotalFoodEatenCat = null;
  15.         for (i = 0; i < days; i++) {
  16.             FoodEatenDog = Integer.parseInt(scanner.nextLine());
  17.             FoodEatenCat = Integer.parseInt(scanner.nextLine());
  18.             totalEatenFood = (FoodEatenDog + FoodEatenCat);
  19.             PercentageTotalEatenFood = (totalEatenFood / food) * 100;
  20.             PercentageTotalFoodEatenDog = (FoodEatenDog / totalEatenFood) * 100;
  21.             PercentageTotalFoodEatenCat = (FoodEatenCat / totalEatenFood) * 100;
  22.             while (days == 3) {
  23.                 biscuits = Math.round((10 * totalEatenFood) / 100);
  24.                 break;
  25.             }
  26.  
  27.         }
  28.         System.out.printf("Total eaten biscuits: %.2f%%.%n", biscuits);
  29.         System.out.printf("%.2f%% of the food has been eaten.%n", PercentageTotalEatenFood);
  30.         System.out.printf("%.2f%% eaten from the dog.%n", PercentageTotalFoodEatenDog);
  31.         System.out.printf("%2f%% eaten from the cat.%n", PercentageTotalFoodEatenCat);
  32.     }
  33. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
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