Advertisement
CR7CR7

04.ThirtyMinutes

Sep 17th, 2022
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P04BackIn30Minutes {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int initHour = Integer.parseInt(scanner.nextLine());
  8.         int initMinutes = Integer.parseInt(scanner.nextLine());
  9.  
  10.         int allMinutes = (initHour * 60) + initMinutes + 30;
  11.  
  12.         int hour = allMinutes / 60;
  13.         int minutes = allMinutes % 60;
  14.  
  15.         if (hour > 23) {
  16.             hour = 0;
  17.         }
  18.  
  19.         System.out.printf("%d:%02d", hour, minutes);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement