Java/Java 알고리즘

백준 10768번 특별한 날 JAVA 구현해보기

kimc 2022. 6. 3. 12:08

```

백준 10768번 특별한 날 JAVA 구현해보기

```

이번 글을 통해 배워갈 내용

  1. 백준 10768번 풀이

https://www.acmicpc.net/problem/10768

 

10768번: 특별한 날

마지막 줄에 "Before", "After"나 "Special"을 출력한다.

www.acmicpc.net

 

백준 10768번 특별한 날은

난이도 브론즈 등급의 문제로서

 

해당 연도 월과 일이 주어지고

2월 18일 이전이면  "Before"

이후면 "After"

당일이면 "Special"을 출력합니다.


30분 정도 위에 링크를 방문하셔서 풀어보시고

안 풀리시는 경우에만 아래 해답을 봐주시면 감사하겠습니다.


입력을 받고

정해진 조건에 맞춰서 계산을 해서 출력해주면 되는

문제입니다.

 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String input01 = br.readLine();
        final String input02 = br.readLine();
        System.out.print(solution(input01, input02));
    }

    private static String solution(String input01, String input02) {

        final int inputMonth = Integer.parseInt(input01);
        final int inputDay = Integer.parseInt(input02);

        final int cccMonth = 2;
        final int cccDay = 18;

        String dateState = "Special";
        if (inputMonth < cccMonth || (inputMonth == cccMonth && inputDay < cccDay)) {
            dateState = "Before";
        } else if (inputMonth > cccMonth || inputDay > cccDay) {
            dateState = "After";
        }

        return dateState;
    }

}

 

읽어주셔서 감사합니다

 

무엇인가 얻어가셨기를 바라며

 

오늘도 즐거운 코딩 하시길 바랍니다 ~ :)

 


 

728x90