본문 바로가기
개발일지/코테 정복기

[Softeer/JAVA] 근무시간(LV.1)

by 리콩알 2024. 6. 7.
반응형

문제 설명

https://softeer.ai/practice/6254

(저작권으로 인해 링크로 대체합니다!)

 

 

코드 풀이

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int hh = 0;
        int mm = 0;

        //월,화,수,목,금
        for(int i=0; i<5; i++){
            String a = sc.next(); //출근 시간 
            String b = sc.next(); //퇴근 시간
            
            String[] atime = a.split(":");
            String[] btime = b.split(":");
            
            hh += Integer.parseInt(btime[0]) - Integer.parseInt(atime[0]);
            mm += Integer.parseInt(btime[1]) - Integer.parseInt(atime[1]);
        }
        System.out.println(hh*60 + mm);
    }
}

 

 

실행 결과

반응형