[Programmers_CT] 4. 병과 분류

문정준's avatar
Feb 04, 2025
[Programmers_CT] 4. 병과 분류
💡
프로그래머스 코딩 테스트 4. 병과 분류
 

1. 문제 설명 - 빈칸 채우기

notion image

제한 사항

notion image

2. 입출력 예시

notion image

3. 코드 작성

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"); } } }
  • lastFourWords가 카테고리의 문자열과 동일해야 함
      1. Ophthalmologyc = _eye : ‘_eye’
      1. Neurosurgery = head : lastFourWords.equals(”head”)
      1. Orthopedics = infl : lastFourWords.equals(”infl”)
      1. Dermatology = skin : else if(lastFourWords.equals(”skin”))
      1. 나머지 경우 : else
 

4. 테스트 결과

notion image

5. 채점

notion image
Share article

sxias