Advertisement
Anamaria93

Untitled

Feb 27th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pets {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int NumberOfDays = Integer.parseInt(scanner.nextLine());
  8. int LeftFood = Integer.parseInt(scanner.nextLine());
  9. double FoodForDogkg = Double.parseDouble(scanner.nextLine());
  10. double FoodForCatkg = Double.parseDouble(scanner.nextLine());
  11. double FoodForTurtleGr = Double.parseDouble(scanner.nextLine());
  12.  
  13. double neededfoodfordog = NumberOfDays * FoodForDogkg;
  14. double neededfoodforcat = NumberOfDays * FoodForCatkg;
  15. double neededfoodforturtle = NumberOfDays * (FoodForTurtleGr / 1000);
  16. double Totalamountoffood = neededfoodfordog + neededfoodforcat + neededfoodforturtle;
  17.  
  18. if (LeftFood > Totalamountoffood)
  19. { double RemainFood = LeftFood - Totalamountoffood;
  20. System.out.printf( "%.0f kilos of food left" , Math.floor(RemainFood)); }
  21. else
  22. {double NeededFood = Totalamountoffood - LeftFood;
  23. System.out.printf( "%.0f more kilos of food are needed." , Math.ceil(NeededFood)) ;}
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement