Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. function three(input) {
  2.  
  3. let fruit = input.shift();
  4. let smallOrBig = input.shift();
  5. let number = Number(input.shift());
  6.  
  7. let sumSmall = 0;
  8. let sumBig = 0;
  9. let finalPrice = 0;
  10.  
  11.  
  12.  
  13. // Watermelon", "Mango", "Pineapple" или "Raspberry
  14. if (fruit === "Watermelon") {
  15. switch (smallOrBig) {
  16. case "small":
  17. sumSmall = 2 * 56;
  18. finalPrice = sumSmall * number;
  19. break;
  20.  
  21. case "big":
  22. sumBig = 5 * 28.70;
  23. finalPrice = sumBig * number;
  24. break;
  25.  
  26. }
  27.  
  28. } else if (fruit === "Mango") {
  29. switch (smallOrBig) {
  30. case "small":
  31. sumSmall = 2 * 33.66;
  32. finalPrice = sumSmall * number;
  33. break;
  34.  
  35. case "big":
  36. sumBig = 5 * 19.60;
  37. finalPrice = sumBig * number;
  38. break;
  39.  
  40. }
  41.  
  42. } else if (fruit === "Pineapple") {
  43. switch (smallOrBig) {
  44. case "small":
  45. sumSmall = 2 * 42.10;
  46. finalPrice = sumSmall * number;
  47. break;
  48.  
  49. case "big":
  50. sumBig = 5 * 24.80;
  51. finalPrice = sumBig * number;
  52. break;
  53.  
  54. }
  55.  
  56. } else if (fruit === "Raspberry") {
  57. switch (smallOrBig) {
  58. case "small":
  59. sumSmall = 2 * 20;
  60. finalPrice = sumSmall * number;
  61. break;
  62.  
  63. case "big":
  64. sumBig = 5 * 15.20;
  65. finalPrice = sumBig * number;
  66. break;
  67.  
  68. }
  69.  
  70. }
  71.  
  72. if (finalPrice >= 400 && finalPrice <= 1000) {
  73. finalPrice = finalPrice * 0.85;
  74. }
  75. if (finalPrice > 1000) {
  76. finalPrice = finalPrice * 0.50;
  77. }
  78.  
  79. console.log(`${finalPrice.toFixed(2)} lv.`)
  80.  
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement