Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. function solve(input) {
  2. let days = Number(input.shift()) - 1
  3. let room = input.shift()
  4. let grade = input.shift()
  5. let price = 0
  6.  
  7. let roomforonepersonprice = 18.00
  8. let apartmentprice = 25.00
  9. let presidentapartmentprice = 35.00
  10.  
  11. if (room == "room for one person") {
  12. if (days < 10) {
  13. price = roomforonepersonprice
  14. } else if (days >= 10 && days <= 15) {
  15. price = roomforonepersonprice
  16. } else if (days > 15) {
  17. price = roomforonepersonprice
  18. }
  19. }
  20. if (room == "apartment") {
  21. if (days < 10) {
  22. price = apartmentprice * 0.70
  23. } else if (days >= 10 && days <= 15) {
  24. price = apartmentprice * 0.65
  25. } else if (days < 15) {
  26. price = apartmentprice * 0.50
  27. }
  28. } if (room == "president apartment") {
  29. if (days < 10) {
  30. price = presidentapartmentprice * 0.90
  31. } else if (days >= 10 && days <= 15) {
  32. price = presidentapartmentprice * 0.85
  33. } else if (days > 15) {
  34. price = presidentapartmentprice * 0.80
  35. }
  36. }
  37.  
  38. if(grade == "positive"){
  39. finalprice = ((price + price * 0.25) * days).toFixed(2)
  40. }else if(grade == 'negative'){
  41. finalprice = ((price - price * 0.10) * days).toFixed(2)
  42. }
  43.  
  44. console.log(finalprice)
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement