Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Objects;
- import java.util.Scanner;
- public class Pets {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int day = Integer.parseInt(scanner.nextLine());
- int foodKg = Integer.parseInt(scanner.nextLine());
- double dogKg = Double.parseDouble(scanner.nextLine());
- double catKg = Double.parseDouble(scanner.nextLine());
- double turtleGr = Double.parseDouble(scanner.nextLine());
- double totalKg = dogKg * day + catKg * day + turtleGr / 1000 * day;
- if (foodKg >= totalKg) {
- System.out.printf("%d kilos of food left.",(int)(foodKg - totalKg));
- } else {
- System.out.printf("%d more kilos of food are needed.", (int)(Math.ceil(totalKg - foodKg)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement