Advertisement
Spocoman

AND Processors

Aug 21st, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function andProcessors(input) {
  2.     let processors = Number(input[0]);
  3.     let workers = Number(input[1]);
  4.     let days = Number(input[2]);
  5.  
  6.     let diff = (processors - Math.floor(workers * days * 8 / 3)) * 110.10;
  7.  
  8.     if (diff > 0) {
  9.         console.log(`Losses: -> ${diff.toFixed(2)} BGN`);
  10.     } else {
  11.         console.log(`Profit: -> ${Math.abs(diff).toFixed(2)} BGN`);
  12.     }
  13. }
  14.  
  15.  
  16. Тарикатско решение и с тернарен оператор:
  17.  
  18. function andProcessors(input) {
  19.     let diff = (Number(input[0]) - Math.floor(Number(input[1]) * Number(input[2]) * 8 / 3)) * 110.10;
  20.     console.log(`${diff > 0 ? 'Losses' : 'Profit'}: -> ${Math.abs(diff).toFixed(2)} BGN`);
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement