deyanivanov966

EXAM 25.10 // 05. Puppy Care

Oct 25th, 2020 (edited)
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.lang.reflect.Array;
  2. import java.util.*;
  3.  
  4. public class StacksAndQueues {
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.  
  8.         int kilos = Integer.parseInt(sc.nextLine());
  9.  
  10.         int ate = 0;
  11.         String command = sc.nextLine();
  12.         while (!command.equals("Adopted")){
  13.             int gr = Integer.parseInt(command);
  14.             ate+=gr;
  15.  
  16.             command = sc.nextLine();
  17.         }
  18.  
  19.  
  20.  
  21.         if (ate<=kilos*1000){
  22.             int diff = kilos*1000 - ate;
  23.             System.out.println("Food is enough! Leftovers: " + diff + " grams.");
  24.         }else {
  25.             int diff = ate - (kilos*1000);
  26.             System.out.printf("Food is not enough. You need %d grams more.", diff);
  27.         }
  28.  
  29.     }
  30. }
Add Comment
Please, Sign In to add comment