Advertisement
GabrielHr00

03. Time + 15 Minutes

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