Advertisement
Spocoman

01. Guinea Pig

Nov 9th, 2023
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function guineaPig(input) {
  2.     let food = Number(input[0]);
  3.     let hay = Number(input[1]);
  4.     let cover = Number(input[2]);
  5.     let weight = Number(input[3]);
  6.  
  7.     for (let i = 1; i <= 30; i++) {
  8.         food -= 0.3;
  9.         if (i % 2 == 0) {
  10.             hay -= food * 0.05;
  11.         }
  12.         if (i % 3 == 0) {
  13.             cover -= weight / 3;
  14.         }
  15.     }
  16.  
  17.     if (food < 0 || hay < 0 || cover < 0) {
  18.         console.log("Merry must go to the pet store!");
  19.     } else {
  20.         console.log(`Everything is fine! Puppy is happy! Food: ${food.toFixed(2)}, Hay: ${hay.toFixed(2)}, Cover: ${cover.toFixed(2)}.`);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement