Portpolio/codingtest

프로그래머스 커피 심부름 풀이

Peter Choi 2025. 2. 26. 21:34
반응형

https://school.programmers.co.kr/learn/courses/30/lessons/181837

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

 

자바

class Solution {
    public int solution(String[] order) {
        int answer = 0;
        
        for (int i=0; i<order.length; i++)
        {
            if(order[i].contains("americano"))
            {
                answer += 4500;
            }
            else if(order[i].contains("cafelatte"))
            {
                answer += 5000;
            }
            else
            {
                answer += 4500;
            }
        }
        return answer;
    }
}

반응형