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 foodInKilograms = Integer.parseInt(scanner.nextLine()),
- availableFoodInGrams = foodInKilograms * 1000;
- String command;
- while (!(command = scanner.nextLine()).equals("Adopted")) {
- availableFoodInGrams -= Integer.parseInt(command);
- }
- if (availableFoodInGrams >= 0) {
- System.out.printf("Food is enough! Leftovers: %d grams.", availableFoodInGrams);
- } else {
- System.out.printf("Food is not enough. You need %d grams more.", Math.abs(availableFoodInGrams));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement