Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let cruise = input.shift();
- let cabin = input.shift();
- let nights = Number(input.shift());
- let price = 0;
- if (cruise == "Mediterranean") {
- if (cabin == "standard cabin") {
- price = (nights * 27.50)*4;
- } else if (cabin == "cabin with balcony") {
- price = (nights * 30.20)*4;
- } else {
- price = (nights * 40.50)*4;
- }
- if (nights >= 7) {
- price -= price * 0.25;
- }
- }
- if (cruise == "Adriatic") {
- if (cabin == "standard cabin") {
- price = (nights * 22.99)*4;
- } else if (cabin == "cabin with balcony") {
- price = (nights * 25.00)*4;
- } else if (cabin == "apartment") {
- price = (nights * 34.99)*4;
- }
- if (nights >= 7) {
- price -= price * 0.25;
- }
- }
- if (cruise == "Aegean") {
- if (cabin == "standard cabin") {
- price = (nights * 23.00)*4;
- } else if (cabin == "cabin with balcony") {
- price = (nights * 26.60)*4;
- } else if (cabin == "apartment") {
- price = (nights * 39.80)*4;
- }
- if (nights >= 7) {
- price -= price * 0.25;
- }
- }
- console.log(`Annie's holiday in the ${cruise} sea costs ${price.toFixed(2)} lv.`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement