Advertisement
veronikaaa86

01. Sum Seconds

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