57. 옷가게 할인 받기

김해준's avatar
Dec 10, 2025
57. 옷가게 할인 받기

사용언어 : Java

문제
notion image
풀이
class Solution { public int solution(int price) { int answer = 0; double dc = 0.0; if(price >= 500000)dc = 0.2; else if( price >= 300000)dc = 0.1; else if(price >= 100000) dc = 0.05; return answer = (int)(price - (price * dc)); } }
notion image
할인을 위한 구매금액은 ‘이상’ 으로 설정되어있다
비교식을 짤때 ‘<’또는’>’가 아니라 ‘<=’ 또는 ‘>=’로 짜야 문제가 생기지 않는다
Share article