Advertisement
CoineTre

JF-Lab04. Back In 30 Minutes

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