Advertisement
vborislavova

07. Alcohol Market - Simple Operations and Calculations

Feb 14th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function alcoholMarket (input) {
  2.     let priceWiskey = Number(input.shift());
  3.     let beerQuantity = Number(input.shift());
  4.     let wineQuantity = Number(input.shift());
  5.     let rakiaQuantity = Number(input.shift());
  6.     let wiskeyQuantity = Number(input.shift());
  7.  
  8.     let rakiaPrice = priceWiskey / 2;
  9.     let winePrice = rakiaPrice - (0.4 * rakiaPrice);
  10.     let beerPrice = rakiaPrice - (0.8 * rakiaPrice);
  11.  
  12.     let rakiaSum = rakiaQuantity * rakiaPrice;
  13.     let wineSum = wineQuantity * winePrice;
  14.     let beerSum = beerQuantity * beerPrice;
  15.     let wiskeySum = wiskeyQuantity * priceWiskey;
  16.    
  17.     let total = rakiaSum + wineSum + beerSum + wiskeySum;
  18.  
  19.     console.log(total.toFixed(2));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement