-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathIfElse.rb
More file actions
29 lines (23 loc) · 837 Bytes
/
IfElse.rb
File metadata and controls
29 lines (23 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
=begin
Complete function saleHotdogs, function accept 1 parameters:n, n is the number
of customers to buy hotdogs, different numbers have different prices (refer to
the following table), return a number that the customer need to pay how much
money.
+---------------+-------------+
| numbers n | price(cents)|
+---------------+-------------+
|n<5 | 100 |
+---------------+-------------+
|n>=5 and n<10 | 95 |
+---------------+-------------+
|n>=10 | 90 |
+---------------+-------------+
You can use if..else or ternary operator to complete it.
When you have finished the work, click "Run Tests" to see if your code is
working properly.
In the end, click "Submit" to submit your code pass this kata.
=end
# My Solution
def sale_hotdogs(n)
n < 5 ? n*100 : n < 10 ? n*95 : n*90
end