Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int foodGrams = Integer.parseInt(scanner.nextLine()) * 1000;
- String command;
- while (!(command = scanner.nextLine()).equals("Adopted")) {
- foodGrams -= Integer.parseInt(command);
- }
- if (foodGrams >= 0) {
- System.out.printf("Food is enough! Leftovers: %d grams.\n", foodGrams);
- } else {
- System.out.printf("Food is not enough. You need %d grams more.\n", Math.abs(foodGrams));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement