Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication6;
- import java.util.Scanner;
- public class CareOfPuppy02 {
- private static int i;
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- Double food = Double.parseDouble(scanner.nextLine());
- double FoodEatenDog, FoodEatenCat, totalEatenFood, biscuits = 0;
- Double PercentageTotalEatenFood = null, PercentageTotalFoodEatenDog = null, PercentageTotalFoodEatenCat = null;
- for (i = 0; i < days; i++) {
- FoodEatenDog = Integer.parseInt(scanner.nextLine());
- FoodEatenCat = Integer.parseInt(scanner.nextLine());
- totalEatenFood = (FoodEatenDog + FoodEatenCat);
- PercentageTotalEatenFood = (totalEatenFood / food) * 100;
- PercentageTotalFoodEatenDog = (FoodEatenDog / totalEatenFood) * 100;
- PercentageTotalFoodEatenCat = (FoodEatenCat / totalEatenFood) * 100;
- while (days == 3) {
- biscuits = Math.round((10 * totalEatenFood) / 100);
- break;
- }
- }
- System.out.printf("Total eaten biscuits: %.2f%%.%n", biscuits);
- System.out.printf("%.2f%% of the food has been eaten.%n", PercentageTotalEatenFood);
- System.out.printf("%.2f%% eaten from the dog.%n", PercentageTotalFoodEatenDog);
- System.out.printf("%2f%% eaten from the cat.%n", PercentageTotalFoodEatenCat);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement