desislava_topuzakova

04. Back In 30 Minutes

Sep 16th, 2021
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. package BasicSyntax_Lab;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class BackIn30Minutes_04 {
  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.         int totalTimeInMinutes = hours * 60 + minutes;
  12.         int timeAfter30Minutes = totalTimeInMinutes + 30;
  13.  
  14.         int finalHour = timeAfter30Minutes / 60;
  15.         int finalMinutes = timeAfter30Minutes % 60;
  16.  
  17.         if(finalHour >= 24) {
  18.             finalHour = 0;
  19.         }
  20.  
  21.         System.out.printf("%d:%02d", finalHour, finalMinutes);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment