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":
- switch (sugar) {
- case "Without":
- totalPrice = drinksCount * 0.9;
- break;
- case "Normal":
- totalPrice = drinksCount * 1.0;
- break;
- case "Extra":
- totalPrice = drinksCount * 1.2;
- break;
- }
- 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;
- }
- if (drink === "Without") {
- let totalPrice = totalPrice - (totalPrice * 0.65);
- } else if (drink === "Espresso" && drinksCount >= 5) {
- totalPrice = totalPrice - (totalPrice * 0.75);
- } else if (totalPrice >= 15) {
- totalPrice = totalPrice - (totalPrice * 0.8);
- }
- console.log(`You bought ${drinksCount} cups of ${drink} for ${(totalPrice).toFixed(2)} lv.`);
- }
- coffeeMachine("Cappuccino", "Normal", "13");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement