Advertisement
myrdok123

01. Sum Seconds

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