Advertisement
CoineTre

Sum Seconds

Oct 13th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SumSeconds {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner (System.in);
  6.         int seconds1 = Integer.parseInt (scanner.nextLine ());
  7.         int seconds2 = Integer.parseInt (scanner.nextLine ());
  8.         int seconds3 = Integer.parseInt (scanner.nextLine ());
  9.         int sumTime = seconds1 + seconds2 + seconds3;
  10.         int timeMinutes = sumTime / 60;
  11.         int timeSeconds = sumTime % 60;
  12.         if (timeSeconds < 10) {
  13.             System.out.printf ("%d:%02d", timeMinutes, timeSeconds);
  14.         } else {
  15.             System.out.printf ("%d:%d", timeMinutes, timeSeconds);
  16.         }
  17.     }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement