Advertisement
desislava_topuzakova

07.SumSeconds

Mar 25th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class test {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.        
  7.         int a = Integer.parseInt(scanner.nextLine());
  8.         int b = Integer.parseInt(scanner.nextLine());
  9.         int c = Integer.parseInt(scanner.nextLine());
  10.        
  11.         int sum = a + b + c;
  12.         int minutes = sum / 60;
  13.         int seconds = sum % 60;
  14.  
  15.         if (seconds >= 10 && seconds <= 59) {
  16.             System.out.println(minutes + ":" + seconds);
  17.         } else if (seconds > 60 && seconds < 119) {
  18.             System.out.println(minutes + ":1" + (seconds - 60));
  19.         } else if (seconds > 120 && seconds < 179) {
  20.             System.out.println(minutes + ":2" + (seconds - 120));
  21.         } else if (seconds < 10) {
  22.             System.out.println(minutes + ":0" + seconds);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement