Advertisement
Ligh7_of_H3av3n

05.PuppyCare

Oct 21st, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package ZadachiOtIzpita2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PyppyCare {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int needFood = Integer.parseInt(scanner.nextLine()) * 1000;
  10.         while (true) {
  11.             String cuurent = scanner.nextLine();
  12.  
  13.             if (cuurent.equals("Adopted")) {
  14.                 break;
  15.             }
  16.             int gramsFood = Integer.parseInt(cuurent);
  17.             needFood -= gramsFood;
  18.         }
  19.  
  20.         if (needFood >= 0) {
  21.             System.out.println("Food is enough! Leftovers: " + needFood + " grams.");
  22.         } else {
  23.             System.out.println("Food is not enough. You need " + needFood * -1 + " grams more.");
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement