Advertisement
desislava_topuzakova

Untitled

Jul 31st, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. function neli(input){
  2. let flowerType = input[0];
  3. let flowersCount = Number(input[1]);
  4. let budget = Number(input[2]);
  5. let rosePrice = 5;
  6. let daliaPrice = 3.8;
  7. let lalePrice = 2.8;
  8. let narcisPrice = 3;
  9. let gladiolaPrice = 2.5;
  10. let total = 0.0
  11. switch(flowerType){
  12. case "Roses":
  13. if(flowersCount>80){
  14. total = rosePrice*flowersCount - (rosePrice*flowersCount*0.1)
  15. }else {
  16. total = rosePrice*flowersCount
  17. }
  18. break;
  19. case "Dahlias":
  20. if(flowersCount>90){
  21. total = daliaPrice*flowersCount - (daliaPrice*flowersCount*0.15)
  22. }else {
  23. total = daliaPrice*flowersCount
  24. }
  25. break;
  26. case "Tulips":
  27. if(flowersCount>80){
  28. total = lalePrice*flowersCount - (lalePrice*flowersCount*0.15)
  29. }else {
  30. total = lalePrice*flowersCount
  31. }
  32. break;
  33. case "Narcissus":
  34. if(flowersCount<120){
  35. total = narcisPrice*flowersCount + (narcisPrice*flowersCount*0.15)
  36. }else {
  37. total = narcisPrice*flowersCount
  38. }
  39. break;
  40. case "Gladiolus":
  41. if(flowersCount<80){
  42. total = gladiolaPrice*flowersCount + (gladiolaPrice*flowersCount*0.2)
  43. }else {
  44. total = gladiolaPrice*flowersCount
  45. }
  46. break;
  47. }
  48. if(budget >= total){
  49. console.log(`Hey, you have a great garden with ${flowersCount} ${flowerType} and ${(budget-total).toFixed(2)} leva left.`);
  50. } else {
  51. console.log(`Not enough money, you need ${(total - budget).toFixed(2)} leva more.`);
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement