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