Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _01_VideoDurations {
- public static void main(String[] args) {
- @SuppressWarnings("resource")
- Scanner input = new Scanner(System.in);
- String duration = input.nextLine();
- int mins = 0;
- int hours = 0;
- while (!duration.equals("End")) {
- String[] split = duration.split(":");
- int getHours = Integer.valueOf(split[0]);
- int getMinutes = Integer.valueOf(split[1]);
- mins += getMinutes;
- hours += getHours;
- if (mins > 59) {
- hours++;
- mins -=60;
- }
- duration = input.nextLine();
- }
- System.out.print(hours);
- System.out.print(":");
- System.out.printf("%02d" , mins);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement