Advertisement
tenachev

SumSeconds

Mar 27th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SumSecond {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int firstCompetitor = Integer.parseInt(scanner.nextLine());
  8.         int secondCompetitor = Integer.parseInt(scanner.nextLine());
  9.         int thirdCompetitor = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int sumSeconds = firstCompetitor + secondCompetitor + thirdCompetitor;
  12.         int minutes = sumSeconds / 60;
  13.         int seconds = sumSeconds % 60;
  14.  
  15.         if (sumSeconds >= 0 && sumSeconds <= 59) {
  16.             if (seconds <= 9) {
  17.                 System.out.println(minutes + ":" + "0" + seconds);
  18.             } else {
  19.                 System.out.println(minutes + ":" + seconds);
  20.             }
  21.         } else if (sumSeconds >= 60 && sumSeconds <= 119) {
  22.             if (seconds <= 9) {
  23.                 System.out.println(minutes + ":" + "0" + seconds);
  24.             } else {
  25.                 System.out.println(minutes + ":" + seconds);
  26.             }
  27.         } else if (sumSeconds >= 120 && sumSeconds <= 179) {
  28.             if (seconds <= 9) {
  29.                 System.out.println(minutes + ":" + "0" + seconds);
  30.             } else {
  31.                 System.out.println(minutes + ":" + seconds);
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement