Advertisement
AlexandrP

Untitled

Nov 17th, 2022
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fruit (input) {
  2.  
  3. fruit = input[0];
  4. day = input[1];
  5. quantity = Number(input[2]);
  6.  
  7. // switch (day){
  8. //         case "Monday":
  9. //         case "Tuesday":
  10. //         case "Wednesday":  
  11. //         case "Thursday":  
  12. //         case "Friday":
  13.  
  14.  
  15. if (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday"){
  16.         switch (fruit) {
  17.             case "banana":
  18.             console.log ((2.50 * quantity).toFixed(2))
  19.             break;
  20.             case "apple":
  21.             console.log ((1.20 * quantity).toFixed(2))
  22.             break;
  23.             case "orange":
  24.             console.log ((0.85 * quantity).toFixed(2))
  25.             break;
  26.             case "grapefruit":
  27.             console.log ((1.45 * quantity).toFixed(2))
  28.             break;
  29.             case "kiwi":
  30.             console.log ((2.70 * quantity).toFixed(2))
  31.             break;
  32.             case "pineapple":
  33.             console.log ((5.50 * quantity).toFixed(2))
  34.             break;
  35.             case "grapes":
  36.             console.log ((3.85 * quantity).toFixed(2))
  37.             break;
  38.             default:console.log("error");break;
  39.         }
  40.  
  41.        
  42.  
  43.             // case "Saturday":
  44.             // case "Sunday":
  45.  
  46.      } else if (day == "Saturday" || day == "Sunday"){
  47.    
  48.             switch (fruit) {
  49.                 case "banana":
  50.                 console.log ((2.70 * quantity).toFixed(2))
  51.                 break;
  52.                 case "apple":
  53.                 console.log ((1.25 * quantity).toFixed(2))
  54.                 break;
  55.                 case "orange":
  56.                 console.log ((0.90 * quantity).toFixed(2))
  57.                 break;
  58.                 case "grapefruit":
  59.                 console.log ((1.60 * quantity).toFixed(2))
  60.                 break;
  61.                 case "kiwi":
  62.                 console.log ((3 * quantity).toFixed(2))
  63.                 break;
  64.                 case "pineapple":
  65.                 console.log ((5.60 * quantity).toFixed(2))
  66.                 break;
  67.                 case "grapes":
  68.                 console.log ((4.20 * quantity).toFixed(2))
  69.                 break;
  70.                 default:console.log("error");break;
  71.             } }
  72.             else {console.log("error")}
  73.         }
  74.  
  75.  
  76. fruit (["banana",
  77. "Monday",
  78. "3"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement