Advertisement
SophiYo

SumSeconds

Dec 13th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package O3_ConditionalConstructions.Exercise;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SumSeconds {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int sporter1 = Integer.parseInt(scanner.nextLine());
  10.         int sporter2 = Integer.parseInt(scanner.nextLine());
  11.         int sporter3 = Integer.parseInt(scanner.nextLine());
  12.  
  13.         int sumTime = sporter1 + sporter2 + sporter3;
  14.         int sumTimeInMinutes = sumTime / 60;
  15.         int seconds = sumTime % 60;
  16.  
  17.         if (seconds >= 10) {
  18.             System.out.printf("%d:%d", sumTimeInMinutes, seconds);
  19.         } else if (seconds < 10) {
  20.             System.out.printf("%d:0%d", sumTimeInMinutes, seconds);
  21.  
  22.         }
  23.  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement