Algorithm/PS

[BOJ/백준] 5342 - Billing [python]

chanwoong1 2023. 3. 15. 11:47
728x90

문제 링크

 

5342번: Billing

The accounting office is having troubling with billing each department for the supplies purchased last semester. Below is a chart of all the supplies and how much they cost. You must write a program that reads a list of the supplies and computes the total

www.acmicpc.net

문제 풀이

각 물건에 해당하는 가격을 저장한 후, 입력값을 받을 때마다 물건의 가격을 더해준다. 출력은 소수점 2번째 자리까지만 출력해준다.

정답 코드

costs = {"Paper" : 57.99, "Printer" : 120.50, "Planners" : 31.25, "Binders" : 22.50, "Calendar" : 10.95, "Notebooks" : 11.20, "Ink" : 66.95}
total = 0
while True :
    s = input()
    if s == "EOI" : break
    total += costs[s]
print("${:.2f}".format(total))
728x90