marian74

Untitled

May 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterCosinacs(budget, priceForKgFlour) {
  2.  
  3.    
  4.     let priceForEgs = priceForKgFlour * 0.75;
  5.     let priceForliterMilk = priceForKgFlour * 1.25;
  6.     let priceForQuarterMilk = priceForliterMilk / 4;
  7.     let priseForCosunac = priceForEgs + priceForQuarterMilk + priceForKgFlour;
  8.     let cosunacs = 0;
  9.     let coloredEggs = 0;
  10.  
  11.     while (budget >= priseForCosunac ) {
  12.         cosunacs++;
  13.         budget -= priseForCosunac;
  14.         coloredEggs += 3;
  15.         if (cosunacs % 3 == 0) {
  16.             coloredEggs -= (cosunacs - 2)
  17.         }
  18.     }
  19.    
  20.     console.log(`You made ${cosunacs} cozonacs! Now you have ${coloredEggs} eggs and ${budget.toFixed(2)}BGN left.`);
  21.    
  22. }
  23. easterCosinacs(15.75, 1.4 )
Add Comment
Please, Sign In to add comment