-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSWEA1976.java
More file actions
47 lines (33 loc) · 1.08 KB
/
SWEA1976.java
File metadata and controls
47 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.study.code.solved;
import java.util.Scanner;
public class SWEA1976 {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
int tcN = sc.nextInt();
for (int tc = 1; tc <= tcN; tc++) {
int fHour = sc.nextInt();
int fMinute = sc.nextInt();
int sHour = sc.nextInt();
int sMinute = sc.nextInt();
int aHour;
if((fHour+sHour)%12 == 0) {
aHour = 12;
}else {
aHour = (fHour+sHour)%12;
}
int aMinute;
if((fMinute+sMinute) >= 60) {
aHour++;
if(aHour > 12) {
aHour = (fHour+sHour)%12;
}
aMinute = (fMinute+sMinute) - 60;
}else {
aMinute = (fMinute+sMinute);
}
System.out.println("#" + tc + " " + aHour + " " + aMinute);
}
sc.close();
}
}