Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SumSeconds {
  4.    
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int sec1 = Integer.parseInt(scanner.nextLine());
  9.         int sec2 = Integer.parseInt(scanner.nextLine());
  10.         int sec3 = Integer.parseInt(scanner.nextLine());
  11.  
  12.         int seconds = sec1 + sec2 + sec3;
  13.         int mins = 0;
  14.        
  15.         if (seconds > 119){
  16.             seconds -= 120;
  17.             mins = 2;
  18.         }else if (seconds > 59){
  19.             seconds -= 60;
  20.             mins = 1;
  21.         }
  22.        
  23.         String secondsString = "";
  24.         if(seconds < 10){
  25.             secondsString = "0";
  26.         }
  27.         secondsString += Integer.toString(seconds);
  28.        
  29.         System.out.printf(mins + ":" + secondsString);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement