Advertisement
PowerCell46

Hotel Room JS

Sep 27th, 2022 (edited)
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hotelRoom(input) {
  2.    
  3. let month = input[0];
  4. let numberOfNights = input[1];
  5.  
  6. let studioPriceForOneNight = 0;
  7. let apartmentPriceForOneNight = 0;
  8.  
  9. if(month == "May" || month == "October") {
  10. studioPriceForOneNight = 50;
  11. apartmentPriceForOneNight = 65;
  12. if(numberOfNights > 7 && numberOfNights <= 14) {
  13. studioPriceForOneNight = studioPriceForOneNight - ((studioPriceForOneNight/100) * 5);
  14. } else if(numberOfNights > 14) {
  15. studioPriceForOneNight = studioPriceForOneNight - ((studioPriceForOneNight/100) * 30);
  16. }
  17. } else if(month == "June" || month == "September") {
  18. studioPriceForOneNight = 75.20;
  19. apartmentPriceForOneNight = 68.70;
  20. if(numberOfNights > 14) {
  21. studioPriceForOneNight = studioPriceForOneNight - ((studioPriceForOneNight/100) * 20);
  22. }
  23. } else if(month == "July" || month == "August") {
  24. studioPriceForOneNight = 76;
  25. apartmentPriceForOneNight = 77;
  26. }
  27.  
  28. if(numberOfNights > 14) {
  29. apartmentPriceForOneNight = apartmentPriceForOneNight - (apartmentPriceForOneNight/10);
  30. }
  31.  
  32. let apartmentFinalSum = apartmentPriceForOneNight * numberOfNights;
  33. let studioFinalSum = studioPriceForOneNight * numberOfNights;
  34.  
  35. console.log("Apartment: " + apartmentFinalSum.toFixed(2) + " lv.");
  36. console.log("Studio: " + studioFinalSum.toFixed(2) + " lv.");
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement