Advertisement
veronikaaa86

04. Back In 30 Minutes

Jan 11th, 2023
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 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 initHours = Integer.parseInt(scanner.nextLine());
  8.         int initMinutes = Integer.parseInt(scanner.nextLine());
  9.  
  10.         //1:46 + 30 -> 1*60 = 60 + 46 + 30 = 136 -> 2:16
  11.         int allMinutes = (initHours * 60) + initMinutes + 30;
  12.  
  13.         int hours = allMinutes / 60;
  14.         int minutes = allMinutes % 60;
  15.  
  16.         if (hours > 23) {
  17.             hours = 0;
  18.         }
  19.  
  20.         System.out.printf("%d:%02d", hours, minutes);
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement