Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hotelRoom(input) {
- let month = input[0]; // May, June, July, August, September или October
- let count_nights = Number(input[1]);
- let priceForStudio;
- let priceForApartment;
- let studioPerNight;
- let apartmentPerNight;
- if (month == "May" || month == "October") {
- studioPerNight = 50;
- apartmentPerNight = 65;
- priceForApartment = apartmentPerNight * count_nights;
- if (count_nights > 7 && count_nights < 14) {
- priceForStudio = (studioPerNight * count_nights) * 0.95;
- } else if (count_nights > 14) {
- priceForStudio = (studioPerNight * count_nights) * 0.70;
- } else {
- priceForStudio = studioPerNight * count_nights;
- }
- } else if (month == "June" || month == "September") {
- studioPerNight = 75.20;
- apartmentPerNight = 68.70;
- priceForApartment = apartmentPerNight * count_nights;
- if (count_nights > 14) {
- priceForStudio = (studioPerNight * count_nights) * 0.80;
- } else {
- priceForStudio = studioPerNight * count_nights;
- }
- } else if (month == "July" || month == "August") {
- studioPerNight = 76;
- apartmentPerNight = 77;
- priceForStudio = studioPerNight * count_nights;
- priceForApartment = apartmentPerNight * count_nights;
- }
- if (count_nights > 14) {
- priceForApartment *= 0.9;
- } else {
- priceForApartment *= 1;
- }
- console.log(`Apartment: ${priceForApartment.toFixed(2)} lv.`);
- console.log(`Studio: ${priceForStudio.toFixed(2)} lv.`);
- }
Add Comment
Please, Sign In to add comment