-
Notifications
You must be signed in to change notification settings - Fork 0
/
Armyvsaliens
56 lines (46 loc) · 2.12 KB
/
Armyvsaliens
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
48
49
50
51
52
53
54
55
56
/* Open Coding Round Code Gladiators 2022
World Army vs Aliens
The world is going to be attacked by the aliens. The space intelligence department has raised an alarm and the world armies are coming together to fight them.
The planning and strategizing is being done to make the maximum impact on the alien ships. The deadly missiles are to be put into action.
The missiles are targeted to destroy the alien ships in space and disable them to land on the Earth.
The army is planning to launch the attack at A time (hh mm) to get an advantage. For each attack, they know the time the missile will require to hit the coming alien ship.
They all are busy in preparation and want to know the time at which the blast will occur and the alien ship will be destroyed in pieces. Can you find the time of the blast ?
Note: The World Army follows a 24-hour time format and you need to find the time of blast accordingly.
The time will be in the hh mm format.Example:
Input Format
The first line of input consists of the launch time in hh mm format separated by space.
The second line of input consists of the travel time for the missile in hh mm format separated by space.
Constraints
00<= hh <=23
00<= mm <=59
Output FormatPrint the time at which the blast will occur and the spaceship will be destroyed.
Sample TestCase 1
Input
19 50
02 20
Output
22 10
*/
import java.util.*;
public class CandidateCode
{
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int fl1 = sc.nextInt();
int fl2 = sc.nextInt();
int sl1= sc.nextInt();
int sl2= sc.nextInt();
fl1+=sl1;
fl2+=sl2;
if (fl1 >= 24) {
fl1 = fl1 % 24;
}
if (fl2 >= 60) {
int n = fl2 / 60;
fl2 = fl2 % 60;
fl1 += n;
fl1 = fl1 % 24;
}
System.out.printf("%02d %02d",fl1, fl2);
}
}