본문 바로가기
Portpolio/codingtest

프로그래머스 병과분류 풀이

by Peter Choi 2025. 2. 10.
반응형

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

자바 풀이

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String code = sc.next();
        String lastFourWords = code.substring(code.length()-4, code.length());

        if(lastFourWords.equals("_eye")){
            System.out.println("Ophthalmologyc");
        }
        else if(lastFourWords.equals("head")){
            System.out.println("Neurosurgery");
        }
        else if(lastFourWords.equals("infl")){
            System.out.println("Orthopedics");
        }
        else if(lastFourWords.equals("skin"))
        {
            System.out.println("Dermatology");
        }
        else
        {
            System.out.println("direct recommendation");
        }
    }
}
반응형

댓글