Advertisement
SUni2020

02. Cat Walking

Mar 29th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P2 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int burnedCaloriesPerMinute = 5;
  7. //На първия ред - минути разходка на ден - цяло число в интервала [1...50]
  8. int walkInMinutesPerDay = Integer.parseInt(scanner.nextLine());
  9. //На втория ред - броят на разходките дневно - цяло число в интервала [1…10]
  10. int numberOfWalksPerDay = Integer.parseInt(scanner.nextLine());
  11. //На третия ред - приетите от котката калории на ден – цяло число в интервала [100…4000]
  12. int caloriesIntakePerDay = Integer.parseInt(scanner.nextLine());
  13. int totalWalk = numberOfWalksPerDay * walkInMinutesPerDay;
  14. int totalBurnedCalories = totalWalk * burnedCaloriesPerMinute;
  15. double enoughBurnedCalories = 0.5 * caloriesIntakePerDay;
  16.  
  17. if ( totalBurnedCalories >= (int)enoughBurnedCalories) {
  18. System.out.printf("Yes, the walk for your cat is enough. Burned calories per day: %d.", totalBurnedCalories);
  19. } else {
  20.  
  21. System.out.printf("No, the walk for your cat is not enough. Burned calories per day: %d.", totalBurnedCalories);
  22. }
  23.  
  24.  
  25.  
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement