desito07

Biscuits Factory

Jun 25th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. function biscuitsFactory(input) {
  2. let productionPerDay = Number(input.shift());
  3. let countWorkers = Number(input.shift());
  4. let productionCompetitor = Number(input.shift());
  5.  
  6. let productionFactory = 0;
  7.  
  8. for (let i = 0; i < 30; i++) {
  9. productionFactory += Math.floor(productionPerDay * countWorkers);
  10.  
  11. if (i % 3 === 0) {
  12. productionFactory -= Math.floor(productionPerDay * countWorkers * 0.25);
  13. }
  14. }
  15. let percentage =
  16. (Math.ceil(productionFactory - productionCompetitor) /
  17. productionCompetitor) *
  18. 100;
  19. console.log(
  20. `You have produced ${productionFactory} biscuits for the past month.`
  21. );
  22. if (productionFactory > productionCompetitor) {
  23. console.log(`You produce ${percentage.toFixed(2)} percent more biscuits.`);
  24. } else {
  25. console.log(
  26. `You produce ${Math.abs(percentage).toFixed(2)} percent less biscuits.`
  27. );
  28. }
  29. }
  30. biscuitsFactory([78, 8, 16000]);
  31. biscuitsFactory([65, 12, 26000]);
Advertisement
Add Comment
Please, Sign In to add comment