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