Advertisement
Liliana797979

moeto viarno reshenie na new house

Jan 28th, 2021
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function newHouse(input) {
  2.     let typeFlour = input[0];
  3.     let floursCount = Number(input[1]);
  4.     let budget = Number(input[2]);
  5.     let totalPrice = 0;
  6.  
  7.     if (typeFlour === "Roses") {
  8.         totalPrice = floursCount * 5;
  9.  
  10.         if (floursCount > 80) {
  11.             totalPrice = totalPrice * 0.9;
  12.         }
  13.  
  14.     } else if (typeFlour === "Dahlias") {
  15.         totalPrice = floursCount * 3.80;
  16.  
  17.         if (floursCount > 90) {
  18.             totalPrice = totalPrice * 0.85;
  19.         }
  20.  
  21.     } else if (typeFlour === "Tulips") {
  22.         totalPrice = floursCount * 2.80;
  23.  
  24.         if (floursCount > 80) {
  25.             totalPrice = totalPrice * 0.85;
  26.         }
  27.  
  28.     } else if (typeFlour === "Narcissus") {
  29.         totalPrice = floursCount * 3.00;
  30.  
  31.         if (floursCount < 120) {
  32.             totalPrice = totalPrice * 1.15;
  33.         }
  34.  
  35.     } else if (typeFlour === "Gladiolus") {
  36.         totalPrice = floursCount * 2.50;
  37.  
  38.         if (floursCount < 80) {
  39.             totalPrice = totalPrice * 1.20;
  40.         }
  41.     }
  42.         if (budget < totalPrice) {
  43.             console.log(`Not enough money, you need ${(totalPrice - budget).toFixed(2)} leva more.`);
  44.            
  45.         } else {
  46.            console.log (`Hey, you have a great garden with ${floursCount} ${typeFlour} and ${(budget - totalPrice).toFixed(2)} leva left.`);
  47.         }
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement