Advertisement
Deiancom

TimePlus15Minutes

Jan 19th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package 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 hourInput = Integer.parseInt(scanner.nextLine());
  9.         int minutesInput = Integer.parseInt(scanner.nextLine());
  10.         int timeInMinutes = hourInput * 60 + minutesInput;
  11.         int timePlus15 = timeInMinutes + 15;
  12.         int finalHour = timePlus15 /60;
  13.         int finalMinutes = timePlus15 %60;
  14.         if (finalHour >= 24) {
  15.             finalHour -= 24;
  16.         }
  17.         if (finalMinutes < 10) {
  18.             System.out.printf("%d:0%d",finalHour,finalMinutes);
  19.         }else {
  20.             System.out.printf("%d:%d",finalHour,finalMinutes);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement