Advertisement
Angel_Kalinkov

SimpleConditionalStatements-Time+15Minutes_AngelKalinkov

Jan 23rd, 2018
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. mport java.util.Scanner;
  2.  
  3. public class TimePlus15minutes {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int hour = Integer.parseInt(scanner.nextLine());
  8.         int minutes = Integer.parseInt(scanner.nextLine());
  9.  
  10.         if (minutes < 45) {
  11.             System.out.printf("%d:%02d%n", hour, (minutes + 15));
  12.         } else if (hour == 23) {
  13.             System.out.printf("0:%02d%n", (minutes - 45));
  14.         } else {
  15.             System.out.printf("%d:%02d%n", (hour + 1), (minutes - 45));
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement