Advertisement
Marin171

JS

Feb 19th, 2023
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. function solve(input) {
  2. let budget = Number(input[0]);
  3. let students = Number(input[1]);
  4. let flourPrice = Number(input[2]);
  5. let eggPrice = Number(input[3]);
  6. let apronPrice = Number(input[4]);
  7.  
  8. let needMoney = apronPrice * (students + students * 0.5) +
  9. eggPrice * 10 * (students) + flourPrice * (students);
  10. console.log(`Items purchased for ${needMoney.toFixed(2)}$.`);
  11. if (budget <= needMoney) {
  12. console.log(`${needMoney.toFixed(2)}$ more needed.`);
  13. }
  14. }
  15. solve([50,
  16. 2,
  17. 1.0,
  18. 0.10,
  19. 10.0])
  20.  
  21. console.log("----")
  22.  
  23. solve([100,
  24. 25,
  25. 4.0,
  26. 1.0,
  27. 6.0])
  28.  
  29. console.log("-----")
  30.  
  31. solve([946,
  32. 20,
  33. 12.05,
  34. 0.42,
  35. 27.89])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement