Advertisement
veronikaaa86

[Java] 07. Sum Seconds

Sep 22nd, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SumSeconds1 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int athlete1 = Integer.parseInt(scanner.nextLine());
  8.         int athlete2 = Integer.parseInt(scanner.nextLine());
  9.         int athlete3 = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int sum = athlete1 + athlete2 + athlete3;
  12.         int minutes = sum/60;
  13.         int seconds = sum%60;
  14.  
  15.         if (seconds<10) {
  16.             System.out.printf("%s:0%s", minutes, seconds);
  17.         } else {
  18.             System.out.printf("%s:%s", minutes, seconds);
  19.         }
  20.  
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement