Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int numOfDays = sc.nextInt();
  7. double leftfoodkg = sc.nextDouble();
  8. double fooddogperdaykg = sc.nextDouble();
  9. double foodcatperdaykg = sc.nextDouble();
  10. double foodturtleperdaygrams = sc.nextDouble();
  11. double dog = numOfDays*fooddogperdaykg;
  12. double cat = numOfDays*foodcatperdaykg;
  13. double turtle = numOfDays*(foodturtleperdaygrams/1000);
  14. double total = dog+cat+turtle;
  15. if(total<=leftfoodkg) {
  16. leftfoodkg -= total;
  17. System.out.printf("%.0f kilos of food left.", Math.floor(leftfoodkg));
  18. }
  19. else if(total>leftfoodkg)
  20. {
  21. total-=leftfoodkg;
  22. System.out.printf("%.0f more kilos of food are needed.",Math.ceil(total));
  23. }
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement