Advertisement
GabrielHr00

01. Sum Seconds

Mar 17th, 2024
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package _02_ConditionalStatements;
  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.         int firstTime = Integer.parseInt(scanner.nextLine());
  9.         int secondTime = Integer.parseInt(scanner.nextLine());
  10.         int thirdTime = Integer.parseInt(scanner.nextLine());
  11.  
  12.         int finalTimeInSeconds = firstTime + secondTime + thirdTime;
  13.         int minutes = finalTimeInSeconds / 60;
  14.         int seconds = finalTimeInSeconds % 60;
  15.  
  16.         if (seconds < 10) {
  17.             System.out.printf("%d:0%d", minutes, seconds);
  18.         } else {
  19.             System.out.printf("%d:%d", minutes, seconds);
  20.         }
  21.  
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement