Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tourAgency(input) {
- let town = input[0];
- let packetType = input[1];
- let isVip = input[2];
- let daySpent = Number(input[3]);
- let priceForADay = 0;
- let finalPrice = 0;
- switch (town) {
- case "Bansko":
- case "Borovets":
- switch (packetType) {
- case "noEquipment":
- if (isVip === "yes") {
- priceForADay = 80 * 0.95;
- } else {
- priceForADay = 80;
- }
- break;
- case "withEquipment":
- if (isVip === "yes") {
- priceForADay = 100 * 0.9;
- } else {
- priceForADay = 100;
- }
- break;
- default:
- console.log("Invalid input!");
- return;
- }
- break;
- case "Varna":
- case "Burgas":
- switch (packetType) {
- case "withBreakfast":
- if (isVip === "yes") {
- priceForADay = 130 * 0.88;
- } else {
- priceForADay = 130;
- }
- break;
- case "noBreakfast":
- if (isVip === "yes") {
- priceForADay = 100 * 0.93;
- } else {
- priceForADay = 100;
- }
- break;
- default:
- console.log("Invalid input!");
- return;
- }
- break;
- default:
- console.log("Invalid input!");
- return;
- }
- if (daySpent < 1) {
- console.log("Days must be positive number!");
- } else {
- finalPrice = priceForADay * daySpent;
- console.log(
- `The price is ${finalPrice.toFixed(2)}lv! Have a nice time!`
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment