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