Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function coffeeMachine(arg1, arg2, arg3) {
- let drink = arg1;
- let sugar = arg2;
- let drinksCount = Number(arg3);
- switch (drink) {
- case "Espresso":
- if (sugar === "Without") {
- totalPrice += drinksCount * 0.9;
- totalPrice -= drinksCount * 0.35;
- break;
- } else if (sugar === "Normal") {
- totalPrice += drinksCount * 1;
- } else if (sugar === "Extra") {
- totalPrice += drinksCount * 1.2;
- }
- break;
- }
- if (drink === "Espresso" && drinksCount >= 5) {
- totalPrice -= totalPrice * 0.25;
- }
- if (totalPrice > 15) {
- totalPrice -= totalPrice * 0.2;
- }
- case "Cappuccino":
- switch (sugar) {
- case "Without":
- totalPrice = drinksCount * 1.0;
- break;
- case "Normal":
- totalPrice = drinksCount * 1.2;
- break;
- case "Extra":
- totalPrice = drinksCount * 1.6;
- break;
- }
- case "Tea":
- switch (sugar) {
- case "Without":
- totalPrice = drinksCount * 0.5;
- break;
- case "Normal":
- totalPrice = drinksCount * 0.6;
- break;
- case "Extra":
- totalPrice = drinksCount * 0.7;
- break;
- }
- break;
- }
- console.log(`You bought ${drinksCount} cups of ${drink} for ${(totalPrice).toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement