Advertisement
Spocoman

03. Harvest

Dec 18th, 2021 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function harvest(input){
  2.     let x = parseFloat(input[0]);
  3.     let y = parseFloat(input[1]);
  4.     let z = parseFloat(input[2]);
  5.     let workers = parseInt(input[3]);
  6.  
  7.     let wine = 0.4 * x * y / 2.5;
  8.  
  9.     if (wine < z) {
  10.         console.log(`It will be a tough winter! More ${Math.floor(z - wine)} liters wine needed.`);
  11.     } else {
  12.         console.log(`Good harvest this year! Total wine: ${Math.floor(wine)} liters.`);
  13.         console.log(`${Math.ceil(wine - z)} liters left -> ${Math.ceil((wine - z) / workers)} liters per person.`);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement