Advertisement
dimipan80

Exam 1. Video Durations

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