Advertisement
myrdok123

P01SumSeconds

Jan 15th, 2023
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package L02ConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P01SumSeconds {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int firstSeconds = Integer.parseInt(scanner.nextLine());
  11.         int secondSeconds = Integer.parseInt(scanner.nextLine());
  12.         int thirdSeconds = Integer.parseInt(scanner.nextLine());
  13.  
  14.         int sumSeconds = firstSeconds + secondSeconds + thirdSeconds;
  15.  
  16.         int minutes = sumSeconds / 60;
  17.         int seconds = sumSeconds % 60;
  18.  
  19.         if (seconds < 10){
  20.             System.out.printf("%d:0%d", minutes, seconds);
  21.         }else {
  22.             System.out.println(minutes + ":" + seconds);
  23.         }
  24.  
  25.  
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement