Advertisement
Guest User

Fruit Shop1

a guest
Jul 21st, 2020
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function magazinZaPlodove(product,dayOfWeek,quantity)
  2. {
  3.     let price = 0;
  4.     let isError = false;
  5.     if(dayOfWeek===`Monday`|| dayOfWeek===`Tuesday`
  6.         || dayOfWeek===` Wednesday` || dayOfWeek===`Thursday` || dayOfWeek===`Friday`)
  7.     {
  8.         switch(product)
  9.         {
  10.             case `banana`:price = 2.50*quantity;break;
  11.             case `apple`:price = 1.20*quantity;break;
  12.             case `orange`:price = 0.85*quantity;break;
  13.             case `grapefruit`:price = 1.45*quantity;break;
  14.             case `kiwi`:price = 2.70*quantity;break;
  15.             case `pineapple`:price = 5.50*quantity;break;
  16.             case `grapes`:price = 3.85*quantity;break;
  17.             default:isError=true;
  18.                 break;
  19.         }
  20.  
  21.     }
  22.  
  23.     else if( dayOfWeek===`Saturday` || dayOfWeek===`Sunday`)
  24.     {
  25.         switch (product) {
  26.             case `banana`:
  27.                 price = 2.70*quantity;
  28.                 break;
  29.             case `apple`:
  30.                 price = 1.25*quantity;
  31.                 break;
  32.             case `orange`:
  33.                 price = 0.90*quantity;
  34.                 break;
  35.             case `grapefruit`:
  36.                 price = 1.60*quantity;
  37.                 break;
  38.             case `kiwi`:
  39.                 price = 3.00*quantity;
  40.                 break;
  41.             case `pineapple`:
  42.                 price = 5.60*quantity;
  43.                 break;
  44.             case `grapes`:
  45.                 price = 4.20*quantity;
  46.                 break;
  47.             default:isError=true;
  48.                 break;
  49.         }
  50.     }
  51.     else
  52.     {
  53.         isError=true;
  54.     }
  55.     if(!isError)
  56.     {
  57.         console.log(price.toFixed(2));
  58.     }
  59. else
  60.     {
  61.         console.log(`error`);
  62.     }
  63.  
  64.  
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement