Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class VideoDuration {
  5.  
  6. /**
  7. * @param args
  8. */
  9. public static void main(String[] args) {
  10. //TODO Auto-generated method stub
  11. Scanner input = new Scanner(System.in);
  12. int result =0;
  13. while (true) {
  14. String videoDuration = input.nextLine();
  15. if (videoDuration.equals("End")) {
  16. break;
  17. }
  18. String[] array = videoDuration.split(":");
  19. int minutes = Integer.parseInt(array[1]);
  20. int hours = Integer.parseInt(array[0]);
  21. result += 60*hours+minutes;
  22.  
  23. }
  24. int hours = result/60;
  25. result = result%60;
  26. //System.out.println(hours+":"+result);
  27. System.out.printf("%d:%02d\n", hours, result);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement