Advertisement
Spocoman

06. Pets

Dec 18th, 2021 (edited)
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pets(input) {
  2.     let day = parseInt(input[0]);
  3.     let foodKg = parseFloat(input[1]);
  4.     let dogKg = parseFloat(input[2]);
  5.     let catKg = parseFloat(input[3]);
  6.     let turtleGr = parseFloat(input[4]);
  7.  
  8.     let totalKg = dogKg * day + catKg * day + turtleGr / 1000 * day;
  9.  
  10.     if (foodKg >= totalKg) {
  11.         console.log(`${Math.floor(foodKg - totalKg)} kilos of food left.`);
  12.     } else {
  13.         console.log(`${Math.ceil(totalKg - foodKg)} more kilos of food are needed.`);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement