Untitled
unknown
java
4 years ago
898 B
9
Indexable
package LastYearExams;
import java.util.Scanner;
public class Dog {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = Integer.parseInt(scan.nextLine());
int foodGrams = n * 1000; //hranata v gramove
int foodCounter = 0;
int dailyGrams = 0;
String command = scan.nextLine();
while (!command.equals("Adopted")) {
dailyGrams = Integer.parseInt(command);
foodCounter = dailyGrams + foodCounter;
command = scan.nextLine();
}
double diff = Math.abs(foodCounter - foodGrams);
if(foodCounter <= foodGrams){
System.out.printf("Food is enough! Leftovers: %.0f grams.", diff);
} else {
System.out.printf("Food is not enough. You need %.0f grams more.", diff);
}
}
}Editor is loading...