Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ConditionalStatementMoreExercises;
- import java.util.Scanner;
- public class Pets {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- int food = Integer.parseInt(scanner.nextLine());
- double dogFood = Double.parseDouble(scanner.nextLine());
- double catFood = Double.parseDouble(scanner.nextLine());
- double turtleFoodInGrams = Double.parseDouble(scanner.nextLine());
- double left = 0;
- double catAndDogFood = days * (dogFood + catFood);
- double turtleFood = days * turtleFoodInGrams / 1000;
- double total = catAndDogFood + turtleFood;
- if (food >= total) {
- left = food - total;
- System.out.printf("%.0f kilos of food left.", Math.floor(left));
- } else {
- left = total - food;
- System.out.printf("%.0f more kilos of food are needed.", Math.ceil(left));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement