Advertisement
myrdok123

P03TimePlus15Minutes

Jan 15th, 2023
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package L02ConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P03TimePlus15Minutes {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int inputHours = Integer.parseInt(scanner.nextLine());
  11.         int inputMinutes = Integer.parseInt(scanner.nextLine());
  12.  
  13.         int totalMinutes = inputHours * 60 + inputMinutes + 15;
  14.  
  15.         int finalHours = totalMinutes / 60;
  16.         int finalMinutes = totalMinutes % 60;
  17.  
  18.         if (finalHours < 24){
  19.             System.out.printf("%d:%02d", finalHours, finalMinutes);
  20.         } else {
  21.             finalHours = 0;
  22.             System.out.printf("%d:%02d", finalHours, finalMinutes);
  23.         }
  24.  
  25.  
  26.  
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement