Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let days = Number(input.shift()) - 1
- let room = input.shift()
- let grade = input.shift()
- let price = 0
- let roomforonepersonprice = 18.00
- let apartmentprice = 25.00
- let presidentapartmentprice = 35.00
- if (room == "room for one person") {
- if (days < 10) {
- price = roomforonepersonprice
- } else if (days >= 10 && days <= 15) {
- price = roomforonepersonprice
- } else if (days > 15) {
- price = roomforonepersonprice
- }
- }
- if (room == "apartment") {
- if (days < 10) {
- price = apartmentprice * 0.70
- } else if (days >= 10 && days <= 15) {
- price = apartmentprice * 0.65
- } else if (days < 15) {
- price = apartmentprice * 0.50
- }
- } if (room == "president apartment") {
- if (days < 10) {
- price = presidentapartmentprice * 0.90
- } else if (days >= 10 && days <= 15) {
- price = presidentapartmentprice * 0.85
- } else if (days > 15) {
- price = presidentapartmentprice * 0.80
- }
- }
- if(grade == "positive"){
- finalprice = ((price + price * 0.25) * days).toFixed(2)
- }else if(grade == 'negative'){
- finalprice = ((price - price * 0.10) * days).toFixed(2)
- }
- console.log(finalprice)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement