Advertisement
Guest User

Untitled

a guest
Oct 28th, 2019
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pipedVal (input){
  2.     let flowersType = (input.shift());
  3.     let flowersCount = Number(input.shift());
  4.     let flowersBudget = Number(input.shift());
  5.     let flowerPrice;
  6.     let allFlowersPrice;
  7.     let moneyLeft;
  8.     let neededMoney;
  9.     let nonFinalPrice;
  10.  
  11.     if (flowersType == "Roses" && flowersCount <= 80){
  12.         flowerPrice = 5;
  13.         allFlowersPrice = (flowerPrice*flowersCount);
  14.         if (allFlowersPrice < flowersBudget){
  15.             moneyLeft = (flowersBudget - allFlowersPrice);
  16.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  17.         }
  18.         if (allFlowersPrice > flowersBudget){
  19.             neededMoney = (allFlowersPrice - flowersBudget);
  20.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  21.         }
  22.     }
  23.     if (flowersType == "Roses" && flowersCount > 80){
  24.         flowerPrice = 5;
  25.         nonFinalPrice = ((flowerPrice*flowersCount));
  26.         allFlowersPrice = (nonFinalPrice - (nonFinalPrice*0.1));
  27.         if (allFlowersPrice < flowersBudget){
  28.             moneyLeft = (flowersBudget - allFlowersPrice);
  29.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  30.         }
  31.         if (allFlowersPrice > flowersBudget){
  32.             neededMoney = (allFlowersPrice - flowersBudget);
  33.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  34.         }
  35.     }
  36.  
  37.     if (flowersType == "Dahlias" && flowersCount <= 90){
  38.         flowerPrice = 3.80;
  39.         allFlowersPrice = (flowerPrice*flowersCount);
  40.         if (allFlowersPrice < flowersBudget){
  41.             moneyLeft = (flowersBudget - allFlowersPrice);
  42.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  43.         }
  44.         if (allFlowersPrice > flowersBudget){
  45.             neededMoney = (allFlowersPrice - flowersBudget);
  46.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  47.         }
  48.     }
  49.     if (flowersType == "Dahlias" && flowersCount > 90){
  50.         flowerPrice = 3.80;
  51.         nonFinalPrice = ((flowerPrice*flowersCount));
  52.         allFlowersPrice = (nonFinalPrice - (nonFinalPrice*0.15));
  53.         if (allFlowersPrice < flowersBudget){
  54.             moneyLeft = (flowersBudget - allFlowersPrice);
  55.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  56.         }
  57.         if (allFlowersPrice > flowersBudget){
  58.             neededMoney = (allFlowersPrice - flowersBudget);
  59.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  60.         }
  61.     }
  62.  
  63.     if (flowersType == "Tulips" && flowersCount <= 80){
  64.         flowerPrice = 2.80;
  65.         allFlowersPrice = (flowerPrice*flowersCount);
  66.         if (allFlowersPrice < flowersBudget){
  67.             moneyLeft = (flowersBudget - allFlowersPrice);
  68.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  69.         }
  70.         if (allFlowersPrice > flowersBudget){
  71.             neededMoney = (allFlowersPrice - flowersBudget);
  72.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  73.         }
  74.     }
  75.     if (flowersType == "Tulips" && flowersCount > 80){
  76.         flowerPrice = 2.80;
  77.         nonFinalPrice = ((flowerPrice*flowersCount));
  78.         allFlowersPrice = (nonFinalPrice - (nonFinalPrice*0.15));
  79.         if (allFlowersPrice < flowersBudget){
  80.             moneyLeft = (flowersBudget - allFlowersPrice);
  81.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  82.         }
  83.         if (allFlowersPrice > flowersBudget){
  84.             neededMoney = (allFlowersPrice - flowersBudget);
  85.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  86.         }
  87.     }
  88.  
  89.     if (flowersType == "Narcissus" && flowersCount >= 120){
  90.         flowerPrice = 3;
  91.         allFlowersPrice = (flowerPrice*flowersCount);
  92.         if (allFlowersPrice < flowersBudget){
  93.             moneyLeft = (flowersBudget - allFlowersPrice);
  94.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  95.         }
  96.         if (allFlowersPrice > flowersBudget){
  97.             neededMoney = (allFlowersPrice - flowersBudget);
  98.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  99.         }
  100.     }
  101.     if (flowersType == "Narcissus" && flowersCount < 120){
  102.         flowerPrice = 3;
  103.         nonFinalPrice = ((flowerPrice*flowersCount));
  104.         allFlowersPrice = (nonFinalPrice + (nonFinalPrice*0.15));
  105.         if (allFlowersPrice < flowersBudget){
  106.             moneyLeft = (flowersBudget - allFlowersPrice);
  107.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  108.         }
  109.         if (allFlowersPrice > flowersBudget){
  110.             neededMoney = (allFlowersPrice - flowersBudget);
  111.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  112.         }
  113.     }
  114.  
  115.     if (flowersType == "Gladiolus" && flowersCount >= 80){
  116.         flowerPrice = 2.50;
  117.         allFlowersPrice = (flowerPrice*flowersCount);
  118.         if (allFlowersPrice < flowersBudget){
  119.             moneyLeft = (flowersBudget - allFlowersPrice);
  120.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  121.             }
  122.         if (allFlowersPrice > flowersBudget){
  123.             neededMoney = (allFlowersPrice - flowersBudget);
  124.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  125.             }
  126.     }
  127.     if (flowersType == "Gladiolus" && flowersCount < 80){
  128.         flowerPrice = 2.50;
  129.         nonFinalPrice = ((flowerPrice*flowersCount));
  130.         allFlowersPrice = (nonFinalPrice + (nonFinalPrice*0.2));
  131.         if (allFlowersPrice < flowersBudget){
  132.             moneyLeft = (flowersBudget - allFlowersPrice);
  133.             console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
  134.             }
  135.         if (allFlowersPrice > flowersBudget){
  136.             neededMoney = (allFlowersPrice - flowersBudget);
  137.             console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
  138.         }
  139.     }
  140.  
  141. }
  142.  
  143.  
  144. pipedVal (['Narcissus','119','360'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement