Advertisement
RRusev77

Small Shop

Mar 28th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(productType, location, volume){
  2.     volume = Number(volume);
  3.    
  4.     let price;
  5.  
  6.     if(location == 'Sofia') {
  7.         switch(productType){
  8.             case 'coffee':
  9.                 price = 0.5 * volume;
  10.                 break;
  11.             case 'water':
  12.                 price = 0.8 * volume;
  13.                 break;
  14.             case 'beer':
  15.                 price = 1.2 * volume;
  16.                 break;
  17.             case 'sweets':
  18.                 price = 1.45 * volume;
  19.                 break;
  20.             case 'peanuts':
  21.                 price = 1.6 * volume;
  22.                 break;
  23.         }
  24.     } else if (location == 'Plovdiv') {
  25.         switch(productType){
  26.             case 'coffee':
  27.                 price = 0.4 * volume;
  28.                 break;
  29.             case 'water':
  30.                 price = 0.7 * volume;
  31.                 break;
  32.             case 'beer':
  33.                 price = 1.15 * volume;
  34.                 break;
  35.             case 'sweets':
  36.                 price = 1.30 * volume;
  37.                 break;
  38.             case 'peanuts':
  39.                 price = 1.5 * volume;
  40.                 break;
  41.         }
  42.     } else if (location == 'Varna') {
  43.         switch(productType){
  44.             case 'coffee':
  45.                 price = 0.45 * volume;
  46.                 break;
  47.             case 'water':
  48.                 price = 0.7 * volume;
  49.                 break;
  50.             case 'beer':
  51.                 price = 1.1 * volume;
  52.                 break;
  53.             case 'sweets':
  54.                 price = 1.35 * volume;
  55.                 break;
  56.             case 'peanuts':
  57.                 price = 1.55 * volume;
  58.                 break;
  59.         }
  60.     }
  61.  
  62.     console.log(price);
  63.    
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement