Skip to content

Instantly share code, notes, and snippets.

@shakyra
Created May 19, 2019 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shakyra/73fa864cac85e6a4e7bc750182849c5a to your computer and use it in GitHub Desktop.
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…
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
}
@3omar-salama
Copy link

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

@Pyger1
Copy link

Pyger1 commented Oct 21, 2023

`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