Nackey

hours:minutes + 15 if - else

Jul 16th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * Created by Nasko on 16.7.2017 г..
  5.  */
  6. public class TimePlus15 {
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.  
  10.         int hours = Integer.parseInt(sc.nextLine());
  11.         int minutes = Integer.parseInt(sc.nextLine());
  12.  
  13.         minutes+=15;
  14.  
  15.         if (minutes>59){
  16.             hours+=1;
  17.             minutes -=60;
  18.         }
  19.  
  20.         if (hours>23) {
  21.             if (minutes < 10) {
  22.                 System.out.printf("0:0%d", minutes);
  23.             } else
  24.                 System.out.printf("0:%d", minutes);
  25.         } else {
  26.             if (minutes < 10) {
  27.                 System.out.printf("%d:0%d",hours, minutes);
  28.             } else {
  29.                 System.out.printf("%d:%d", hours, minutes);
  30.             }
  31.         }
  32.  
  33.  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment