nikolayneykov

Untitled

Mar 2nd, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve([budget, students, flourPrice, eggPrice, apronPrice]) {
  2.     let freePackages = Math.floor(students / 5);                 //изчисляваме безплатните пакети брашно
  3.  
  4.     let totalPrice = (apronPrice * Math.ceil(students * 1.2)) +  //цена за aprons (студентите ги увеличаваме с 20% и закръгляме нагоре)
  5.                      (eggPrice * 10 * students) +                //цена за яйцата
  6.                      (flourPrice * (students - freePackages));   //цена за бращното минус безплатните пакети
  7.    
  8.     console.log(budget >= totalPrice ?                           //принтираме резултата
  9.         `Items purchased for ${totalPrice.toFixed(2)}$.` :
  10.         `${(totalPrice - budget).toFixed(2)}$ more needed.`);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment