-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathAlarm.java
23 lines (21 loc) · 883 Bytes
/
Alarm.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package alarm;
import java.io.*;
import java.util.*;
public class Alarm {
public static void main(String[] args) throws IOException {
ArrayList<Integer> time = new ArrayList<>();
int result;
String str;
FileReader file = new FileReader("input.txt"); // Считывание данных из файла
Scanner sc = new Scanner(file);
str = sc.nextLine();
StringTokenizer st = new StringTokenizer(str, " ");
while (st.hasMoreTokens()){
time.add(Integer.valueOf(st.nextToken())); // Записать все элементы в коллекцию
}
result = (time.get(1) > time.get(0)) ? time.get(1) - time.get(0) : 12 + time.get(1) - time.get(0);
FileWriter fileOut = new FileWriter("output.txt");
fileOut.write(String.valueOf(result));
fileOut.close();
}
}