Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ZadachiOtIzpita2;
- import java.util.Scanner;
- public class PyppyCare {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int needFood = Integer.parseInt(scanner.nextLine()) * 1000;
- while (true) {
- String cuurent = scanner.nextLine();
- if (cuurent.equals("Adopted")) {
- break;
- }
- int gramsFood = Integer.parseInt(cuurent);
- needFood -= gramsFood;
- }
- if (needFood >= 0) {
- System.out.println("Food is enough! Leftovers: " + needFood + " grams.");
- } else {
- System.out.println("Food is not enough. You need " + needFood * -1 + " grams more.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement