ProdanTenev

smallShop

Feb 12th, 2022 (edited)
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.44 KB | None | 0 0
  1. function smallShop(input) {
  2.     let product = String(input[0]);
  3.     let town = String(input[1]);
  4.     let quantity = Number(input[2]);
  5.     let sum = 0;
  6.     if (town == "Sofia") {
  7.         if (product == "coffee") {
  8.             sum = quantity * 0.5;
  9.         } else if (product == "water") {
  10.             sum = quantity * 0.8;
  11.         } else if (product == "beer") {
  12.             sum = quantity * 1.2;
  13.         } else if (product == "sweets") {
  14.             sum = quantity * 1.45;
  15.         } else if (product == "peanuts") {
  16.             sum = quantity * 1.6;
  17.         }
  18.     } else if (town == "Plovdiv") {
  19.         if (product == "coffee") {
  20.                 sum = quantity * 0.4;
  21.         } else if (product == "water") {
  22.             sum = quantity * 0.7;
  23.         } else if (product == "beer") {
  24.             sum = quantity * 1.15;
  25.         } else if (product == "sweets") {
  26.             sum = quantity * 1.30;
  27.         } else if (product == "peanuts") {
  28.             sum = quantity * 1.5;
  29.         }
  30.     } else if (town == "Varna") {
  31.         if (product == "coffee") {
  32.             sum = quantity * 0.45;
  33.         } else if (product == "water") {
  34.             sum = quantity * 0.7;
  35.         } else if (product == "beer") {
  36.             sum = quantity * 1.1;
  37.         } else if (product == "sweets") {
  38.             sum = quantity * 1.35;
  39.         } else if (product == "peanuts") {
  40.             sum = quantity * 1.55;
  41.         }
  42.     }
  43.     console.log(sum);
  44. }
Add Comment
Please, Sign In to add comment