[프로그래머스 LV0] 옷가게 할인 받기

jonghwan·2022년 10월 13일
0

프로그래머스

목록 보기
35/71
post-thumbnail

1. 문제 설명

옷가게 할인 받기

2. 문제 분석

50만원 이상이면 price - price x 0.80
30만원 이상이면 price - price x 0.90
10만원 이상이면 price - price x 0.95

3. 나의 풀이

import Foundation

func solution(_ price:Int) -> Int {
    switch price {
    case 100000..<300000:
        return Int(Double(price) * 0.95)
    case 300000..<500000:
        return Int(Double(price) * 0.90)
    case 500000...:
        return Int(Double(price) * 0.80)
    default:
        return price
    }
}

0개의 댓글