Created
May 19, 2019 14:02
-
-
Save shakyra/73fa864cac85e6a4e7bc750182849c5a to your computer and use it in GitHub Desktop.
After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you. You will need a rental car in order for you to get around in your vacation. The manager of the car rental makes you some good offers. Every day you rent the car costs $40. I…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func RentalCarCost(_ days: Int) -> Int { | |
let costPerDay = 40 | |
var totalCost = costPerDay * days | |
if (days >= 7) { | |
totalCost -= 50 | |
} | |
else if (days >= 3) { | |
totalCost -= 20 | |
} | |
return totalCost | |
} |
`def rental_car_cost(d):
rent_day = 40
if d >= 7:
total = 40 * d - 50
elif d >= 3:
total = 40 * d - 20
else:
total = 40 * d
return total
#any non-negative number
print(rental_car_cost(d=18))`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def rental_car_cost(d)
#Write your code here
cost=40
total=cost*d
if d >= 1 && d < 3
return total
elsif d >= 3 && d < 7
return total -= 20
elsif d > 7
return total -= 50
end
end