Advertisement
veronikaaa86

01. SumSeconds

Jun 13th, 2021
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. package conditionalStatements;
  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 firstNum = Integer.parseInt(scanner.nextLine());
  10. int secondNum = Integer.parseInt(scanner.nextLine());
  11. int thirdNum = Integer.parseInt(scanner.nextLine());
  12.  
  13. int sum = firstNum + secondNum + thirdNum;
  14.  
  15. int minutes = sum / 60;
  16. int seconds = sum % 60;
  17.  
  18. if (seconds < 10) {
  19. System.out.printf("%d:0%d", minutes, seconds);
  20. } else {
  21. System.out.printf("%d:%d", minutes, seconds);
  22. }
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement