Advertisement
GabrielHr00

03. Time + 15 Minutes

Mar 17th, 2024
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. package _02_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.  
  13.         if (minutes >= 60) {
  14.             minutes = minutes - 60;
  15.             hours = hours + 1;
  16.         }
  17.  
  18.         if (hours > 23) {
  19.             hours = 0;
  20.         }
  21.  
  22.         System.out.printf("%d:%02d", hours, minutes);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement