Advertisement
veronikaaa86

04. Back In 30 Minutes

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