Advertisement
Peci95

+15 minutes

Mar 25th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class fifteenMinutes {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int hours = Integer.parseInt(scanner.nextLine());
  7.         int minutes = Integer.parseInt(scanner.nextLine());
  8.         int sumH = (hours * 60 + minutes + 15) / 60;
  9.         int sumM = (hours * 60 + minutes + 15) % 60;
  10.         if(hours == 23)
  11.         {
  12.             if (minutes >= 45)
  13.             {
  14.                 if (sumM < 10) {
  15.                     System.out.printf("0:0%d", sumM);
  16.                 } else {
  17.                     System.out.printf("0:%d", sumM);
  18.                 }
  19.             }
  20.             else
  21.             {
  22.                 if (sumM < 10) {
  23.                     System.out.printf("%d:0%d", sumH, sumM);
  24.                 } else {
  25.                     System.out.printf("%d:%d", sumH, sumM);
  26.                 }
  27.             }
  28.         }
  29.         else
  30.         {
  31.             if (sumM < 10) {
  32.                 System.out.printf("%d:0%d", sumH, sumM);
  33.             } else {
  34.                 System.out.printf("%d:%d", sumH, sumM);
  35.             }
  36.         }
  37.  
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement