dakata450

Untitled

Jun 14th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. package ConditionaStatments;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Pets {
  6. public static void main(String[] args) {
  7. Scanner scanne = new Scanner(System.in);
  8. int numberdays = Integer.parseInt(scanne.nextLine());
  9. int leftFood = Integer.parseInt(scanne.nextLine());
  10. double dogFoodKg = Double.parseDouble(scanne.nextLine());
  11. double catFoodKg = Double.parseDouble(scanne.nextLine());
  12. double turtleFoodGg = Double.parseDouble(scanne.nextLine());
  13. double dogfoodNeed = numberdays * dogFoodKg;
  14. double catfoodNeeded = numberdays * catFoodKg;
  15. double turtlefoodneed = (numberdays * turtleFoodGg) / 1000;
  16. double totalFood = dogfoodNeed + catfoodNeeded + turtlefoodneed;
  17. if (leftFood > totalFood){
  18. System.out.printf("%.0f kilos of food left.", Math.floor(leftFood - totalFood));
  19. }else {
  20. System.out.printf("%.0f more kilos of food are needed.", Math.ceil(totalFood - leftFood));
  21. }
  22.  
  23.  
  24.  
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment