Advertisement
AlexandrP

Untitled

Nov 17th, 2022 (edited)
99
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.         switch (fruit) {
  15.             case "banana":
  16.             console.log (2.50 * quantity)
  17.             break;
  18.             case "apple":
  19.             console.log ((1.20 * quantity).toFixed(2))
  20.             break;
  21.             case "orange":
  22.             console.log ((0.85 * quantity).toFixed(2))
  23.             break;
  24.             case "grapefruit":
  25.             console.log ((1.45 * quantity).toFixed(2))
  26.             break;
  27.             case "kiwi":
  28.             console.log ((2.70 * quantity).toFixed(2))
  29.             break;
  30.             case "pineapple":
  31.             console.log ((5.50 * quantity).toFixed(2))
  32.             break;
  33.             case "grapes":
  34.             console.log ((3.85 * quantity).toFixed(2))
  35.             break;
  36.             default:console.log("error");break;
  37.         }
  38.  
  39.         break;
  40.  
  41.             case "Saturday":
  42.             case "Sunday":
  43.    
  44.             switch (fruit) {
  45.                 case "banana":
  46.                 console.log ((2.70 * quantity).toFixed(2))
  47.                 break;
  48.                 case "apple":
  49.                 console.log ((1.25 * quantity).toFixed(2))
  50.                 break;
  51.                 case "orange":
  52.                 console.log ((0.90 * quantity).toFixed(2))
  53.                 break;
  54.                 case "grapefruit":
  55.                 console.log ((1.60 * quantity).toFixed(2))
  56.                 break;
  57.                 case "kiwi":
  58.                 console.log ((3 * quantity).toFixed(2))
  59.                 break;
  60.                 case "pineapple":
  61.                 console.log ((5.60 * quantity).toFixed(2))
  62.                 break;
  63.                 case "grapes":
  64.                 console.log ((4.20 * quantity).toFixed(2))
  65.                 break;
  66.                 default:console.log("error");break;
  67.             } break;
  68.             default:console.log("error");break;
  69.         }}
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement