du4ko

Task One Exam One

Jun 9th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class VideoDuration {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scan = new Scanner(System.in);
  7.         int hours = 0;
  8.         int minutes = 0;
  9.         while (true) {
  10.             String input = scan.nextLine();
  11.             if (input.equals("End")) {
  12.                 break;
  13.             }
  14.             String[] array = input.split(":");
  15.             hours += Integer.parseInt(array[0]);
  16.             minutes +=Integer.parseInt(array[1]);
  17.             if (minutes >= 60) {
  18.                 minutes -= 60;
  19.                 hours++;
  20.             }
  21.         }
  22.         System.out.printf(hours +":" + "%02d", minutes);
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment