Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve1(input) {
- let foodInKilograms = Number(input[0]);
- //console.log(foodInKilograms);
- let hayInKilograms = Number(input[1]);
- //console.log(hayInKilograms);
- let coverInKilograms = Number(input[2]);
- //console.log(coverInKilograms);
- let guineaWeightInKilograms = Number(input[3]);
- // console.log(guineaWeightInKilograms);
- let day = 0;
- let foodInGrames = foodInKilograms * 1000;
- let foodInGramesInDay = foodInGrames - 300;
- let food = foodInGrames - 9000;
- let hayInGrames = hayInKilograms * 1000;
- let coverInGrames = coverInKilograms * 1000;
- let weigthInGrames = guineaWeightInKilograms * 1000;
- let foodInDay = (foodInGrames / 30).toFixed(2);
- let foodInTwoDay = foodInGrames - 600;
- console.log(foodInTwoDay);
- let hay = 0;
- let cover = 0;
- let hayInDay = hayInGrames - hay;
- if (day % 2 === 0) {
- hayIn = foodInTwoDay * 0.05;
- }
- let hayU = hayInGrames - hayIn;
- if (day % 3 === 0) {
- cover = coverInGrames - weigthInGrames / 3;
- }
- while (foodInGrames >= 0) {
- day++;
- if(foodInGrames > 0 && hayInGrames > 0 && weigthInGrames > 0) {
- console.log(`Everything is fine! Puppy is happy! Food: ${(food / 1000).toFixed(2)}, Hay: ${(hayInGrames/15).toFixed(2)}, Cover: ${cover.toFixed(2)}`);
- } else if (foodInGrames == 0 || hayInGrames == 0 || coverInGrames == 0) {
- console.log(`Marry must go to pet store!`);
- }
- break;
- }
- }
- solve1(["10",
- "5",
- "5.2",
- "1"]);
Advertisement
Add Comment
Please, Sign In to add comment