Advertisement
SotirovG

TimeAfter15Minutes

Sep 23rd, 2020
156
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. public class TimeAfter15Minutes {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int hour = Integer.parseInt(scanner.nextLine());
  8.         int min = Integer.parseInt(scanner.nextLine());
  9.  
  10.         int hourInMin = hour * 60;
  11.         int restMin = min % 60;
  12.         int totalTimeInMin = hourInMin + restMin;
  13.         int timeAfter15inMin = totalTimeInMin + 15;
  14.         int newTimeHours = timeAfter15inMin / 60;
  15.         int newTimeMin = timeAfter15inMin % 60;
  16.         if (newTimeHours == 24){
  17.             newTimeHours = 0;
  18.         }
  19.         if (newTimeMin < 10){
  20.             System.out.printf("%d:0%d",newTimeHours,newTimeMin);
  21.         } else{
  22.             System.out.printf("%d:%d",newTimeHours,newTimeMin);
  23.         }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement