You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/concept/vehicle-purchase/.docs/instructions.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,17 @@ You have three tasks, one to determine if you will need one to help you choose b
9
9
The auto dealers in your town are all running a five year, 0% interest promotion that you would like to take advantage of.
10
10
But you are not sure if you can afford the monthly payments on the car you want.
11
11
12
+
The monthly payment is the cars total price divided by the number of months under the five year period.
13
+
12
14
Implement the `canIBuy(vehicle:price:monthlyBudget:)` function that takes the following arguments:
13
15
-`vehicle` - The name of the vehicle you want to buy.
14
16
-`price` - The price of the vehicle you want to buy.
15
17
-`monthlyBudget` - The amount of money you can afford to pay each month.
16
18
17
19
The function should return the following message based on the following conditions:
18
-
- If the price of the vehicle is less than or equal to the monthly budget, return the message `"Yes! I'm getting a <vehicle>"`.
19
-
- If the price of the vehicle is 10% above your monthly budget, return the message `"I'll have to be frugal if I want a <vehicle>"`.
20
-
- If the price of the vehicle is more than 10% above your monthly budget, return the message `"Darn! No <vehicle> for me"`.
20
+
- If the monthly payment of the vehicle is less than or equal to the monthly budget, return the message `"Yes! I'm getting a <vehicle>"`.
21
+
- If the monthly payment of the vehicle is above your monthly budget by up to 10% (inclusive), return the message `"I'll have to be frugal if I want a <vehicle>"`.
22
+
- If the monthly payment of the vehicle is more than 10% above your monthly budget, return the message `"Darn! No <vehicle> for me"`.
21
23
22
24
```swift
23
25
canIBuy(vehicle: "1974 Ford Pinto", price: 516.32, monthlyBudget: 100.00)
0 commit comments