Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.lang.reflect.Array;
- import java.util.*;
- public class StacksAndQueues {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int kilos = Integer.parseInt(sc.nextLine());
- int ate = 0;
- String command = sc.nextLine();
- while (!command.equals("Adopted")){
- int gr = Integer.parseInt(command);
- ate+=gr;
- command = sc.nextLine();
- }
- if (ate<=kilos*1000){
- int diff = kilos*1000 - ate;
- System.out.println("Food is enough! Leftovers: " + diff + " grams.");
- }else {
- int diff = ate - (kilos*1000);
- System.out.printf("Food is not enough. You need %d grams more.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement