Advertisement
Spocoman

Deer of Santa

Sep 4th, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int days = Integer.parseInt(scanner.nextLine());
  7.         double availableFood = Double.parseDouble(scanner.nextLine()),
  8.                 deer1 = Double.parseDouble(scanner.nextLine()),
  9.                 deer2 = Double.parseDouble(scanner.nextLine()),
  10.                 deer3 = Double.parseDouble(scanner.nextLine());
  11.  
  12.         availableFood -= (deer1 + deer2 + deer3) * days;
  13.  
  14.         if (availableFood >= 0) {
  15.             System.out.println(Math.floor(availableFood) + " kilos of food left.");
  16.         } else {
  17.             System.out.println(Math.ceil(Math.abs(availableFood)) + " more kilos of food are needed.");
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement