Untitled

mail@pastecode.io avatar
unknown
java
3 years ago
898 B
5
Indexable
Never
package LastYearExams;

import java.util.Scanner;

public class Dog {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n = Integer.parseInt(scan.nextLine()); 

        int foodGrams = n * 1000;  //hranata v gramove

        int foodCounter = 0;

        int dailyGrams = 0;

        String command = scan.nextLine();

        while (!command.equals("Adopted")) {
            dailyGrams = Integer.parseInt(command);
            foodCounter = dailyGrams + foodCounter;

            command = scan.nextLine();
        }
        double diff = Math.abs(foodCounter - foodGrams);
        if(foodCounter <= foodGrams){
            System.out.printf("Food is enough! Leftovers: %.0f grams.", diff);
        } else {
            System.out.printf("Food is not enough. You need %.0f grams more.", diff);
        }
    }
}