[백준/파이썬] 14182번 풀이

업데이트:



문제 정보


풀이

문제

The amount of income tax imposed on any taxpayer depends on his/her income. For an income less than or equal to 1,000,000 Oshloobs, no tax is paid. For an income greater than 1,000,000 and less than or equal to 5,000,000 Oshloobs, the tax is 10% of the income. For an income over 5,000,000 Oshloobs, the tax is 20% of the income. You should write a program to calculate the net income of any given employee after the deducted tax.

입력 요약
There are multiple lines in the input. Each line contains an employee’s income before the tax, which is a positive integer, a multiple of 1000, and not greater than 10,000,000. The input terminates with a line containing 0 which should not be processed.

출력 요약
For each employee, output a line containing the net income after the deducted tax.

코드

while True:
    n=int(input())
    if n==0:break
    if 5000000>=n>1000000:n*=0.9
    if 5000000<n:n*=0.8
    print(int(n))

설명

핵심은 구현 관점에서 The amount of income tax imposed on any taxpayer depends on his/her income. For an income less than or equal to 1,000,000 Oshloobs, no tax is paid. …를 만족하도록 로직을 구성하는 것입니다.

코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.

경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.



다음 읽을거리

관련 허브 페이지에서 같은 주제의 글을 이어서 확인할 수 있습니다.

댓글남기기