Advertisement
psi_mmobile

Untitled

Oct 20th, 2022
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         double food = 0.0;
  4.         double hay = 0.0;
  5.         double cover = 0.0;
  6.         double weight = 0.0;
  7.        
  8.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  9.         food = scanner.nextDouble() * 1000;
  10.         hay = scanner.nextDouble() * 1000;
  11.         cover = scanner.nextDouble() * 1000;
  12.         weight = scanner.nextDouble() * 1000;
  13.        
  14.         int days = 30;
  15.        
  16.         for (int day = 1; day <= 30; day++) {
  17.             food -= 300;
  18.             if (day % 2 == 0) {
  19.                 hay -= (0.05 * food);
  20.             }
  21.             if (day % 3 == 0) {
  22.                 cover -= (weight * 0.3333333333333333333);
  23.             }
  24.             if (food <= 0 || hay <= 0 || cover <= 0) {
  25.                 System.out.println("Merry must go to the store!");
  26.                 break;
  27.             }
  28.         }
  29.         if (food > 0 && hay > 0 && cover > 0) {
  30.             System.out.printf("Everything is fine! Puppy is happy! Food: %.2f, Hay: %.2f, Cover: %.2f.",food * 0.001,hay * 0.001,cover*0.001);
  31.         }
  32.        
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement