Advertisement
Spocoman

07. Flower Shop

Dec 18th, 2021 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function flowerShop(input) {
  2.     let magnolia = parseInt(input[0]);
  3.     let hyacinth = parseInt(input[1]);
  4.     let rose = parseInt(input[2])
  5.     let cactus = parseInt(input[3]);
  6.     let gift = parseFloat(input[4]);
  7.  
  8.     let total = (magnolia * 3.25 + hyacinth * 4 + rose * 3.5 + cactus * 8) * 0.95;
  9.    
  10.     if (total >= gift){
  11.         console.log(`She is left with ${Math.floor(total - gift)} leva.`);
  12.     } else {
  13.         console.log(`She will have to borrow ${Math.ceil(gift - total)} leva.`);
  14.     }
  15. }
  16.  
  17.  
  18. Taрикатско решение:)
  19.  
  20. function flowerShop(input) {
  21.    
  22.     let total = (parseInt(input[0]) * 3.25 + parseInt(input[1]) * 4 + parseInt(input[2]) * 3.5 + parseInt(input[3]) * 8) * 0.95;
  23.    
  24.     if (total >= parseFloat(input[4])){
  25.         console.log(`She is left with ${Math.floor(total - parseFloat(input[4]))} leva.`);
  26.     } else {
  27.         console.log(`She will have to borrow ${Math.ceil(parseFloat(input[4]) - total)} leva.`);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement