Advertisement
desislava_topuzakova

SumSeconds

Apr 5th, 2018
174
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 Problem7_SumSeconds {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int a = Integer.parseInt(scanner.nextLine());
  7.         int b = Integer.parseInt(scanner.nextLine());
  8.         int c = Integer.parseInt(scanner.nextLine());
  9.         int sum = a + b + c;
  10.         int minutes = sum / 60;
  11.         int seconds = sum % 60;
  12.  
  13.         if (seconds >= 10 && seconds <= 59) {
  14.             System.out.println(minutes + ":" + seconds);
  15.         } else if (seconds > 60 && seconds < 119) {
  16.             System.out.println(minutes + ":1" + (seconds - 60));
  17.         } else if (seconds > 120 && seconds < 179) {
  18.             System.out.println(minutes + ":2" + (seconds - 120));
  19.         } else if (seconds < 10) {
  20.             System.out.println(minutes + ":0" + seconds);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement