Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.Integer;
- public class Pets {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int daysAway = Integer.parseInt(console.nextLine());
- int foodLeftInKilos = Integer.parseInt(console.nextLine());
- double dogsFoodKgDay = Double.parseDouble(console.nextLine());
- double catsFoodKgDay = Double.parseDouble(console.nextLine());
- double turtleFoodGrDay = Double.parseDouble(console.nextLine());
- double dogsFood = dogsFoodKgDay * daysAway;
- double catsFood = catsFoodKgDay * daysAway;
- double turtlesFood= (turtleFoodGrDay * daysAway) / 1000;
- double allAnimalsFood = dogsFood + catsFood + turtlesFood;
- double enoughtFood = foodLeftInKilos - allAnimalsFood;
- if( enoughtFood >= 0){
- enoughtFood = Math.floor(enoughtFood);
- System.out.println((int)enoughtFood + " kilos of food left.");
- }else if (enoughtFood < 0 ){
- enoughtFood = Math.abs(enoughtFood);
- enoughtFood = Math.ceil(enoughtFood);
- System.out.println((int)enoughtFood + " more kilos of food are needed.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment