Advertisement
Guest User

Untitled

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