Advertisement
Liliana797979

vqrno reshenie na coffee machine

Dec 23rd, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function coffeeMachine(arg1, arg2, arg3) {
  2.     let drink = arg1;
  3.     let sugar = arg2;
  4.     let drinksCount = Number(arg3);
  5.     let totalPrice = 0;
  6.  
  7.     switch (drink) {
  8.         case "Espresso":
  9.             if (sugar === "Without") {
  10.                 totalPrice += drinksCount * 0.9;
  11.                 totalPrice -= totalPrice * 0.35;
  12.             } else if (sugar === "Normal") {
  13.                 totalPrice += drinksCount * 1;
  14.             } else if (suggar === "Extra") {
  15.                 totalPrice += drinksCount * 1.20;
  16.             }
  17.             break;
  18.  
  19.     }
  20.     if (drink === "Espresso" && drinksCount >= 5) {
  21.         totalPrice -= totalPrice * 0.25;
  22.     }
  23.     if (totalPrice >= 15) {
  24.         totalPrice -= totalPrice * 0.20;
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement