Advertisement
Spocoman

05. Pets

Aug 24th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. import java.util.Objects;
  2. import java.util.Scanner;
  3.  
  4. public class Pets {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int day = Integer.parseInt(scanner.nextLine());
  8.         int foodKg = Integer.parseInt(scanner.nextLine());
  9.         double dogKg = Double.parseDouble(scanner.nextLine());
  10.         double catKg = Double.parseDouble(scanner.nextLine());
  11.         double turtleGr = Double.parseDouble(scanner.nextLine());
  12.  
  13.         double totalKg = dogKg * day + catKg * day + turtleGr / 1000 * day;
  14.         if (foodKg >= totalKg) {
  15.             System.out.printf("%d kilos of food left.",(int)(foodKg - totalKg));
  16.         } else {
  17.             System.out.printf("%d more kilos of food are needed.", (int)(Math.ceil(totalKg - foodKg)));
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement