Advertisement
MladenKarachanov

Pets

Jan 24th, 2024
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. package programmingBasics;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Pets {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int numDays = Integer.parseInt(scanner.nextLine());
  9.         int foodLeftBehindKilograms = Integer.parseInt(scanner.nextLine());
  10.         double daysKilogramDog = Double.parseDouble(scanner.nextLine());
  11.         double daysFoodCat = Double.parseDouble(scanner.nextLine());
  12.         double daysFoodTurtle = Double.parseDouble(scanner.nextLine());
  13.         double conversion=daysFoodTurtle/1000;
  14.         double sum = (numDays * daysKilogramDog)
  15.                 + (numDays * daysFoodCat)
  16.                 + (numDays * conversion);
  17.  
  18.         if (sum <= foodLeftBehindKilograms) {
  19.             double result = Math.abs(sum - foodLeftBehindKilograms);
  20.             System.out.printf("%.0f kilos of food left", Math.floor(result));
  21.  
  22.         } else {
  23.                 double totalFinish = Math.abs(foodLeftBehindKilograms-sum);
  24.                 System.out.printf("%.0f more kilos of food are needed", Math.ceil(totalFinish));
  25.             }
  26.  
  27.  
  28.         }
  29.     }
  30.  
  31. //НЕ Е РЕШЕНА
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement