Advertisement
desislava_topuzakova

Airplane 1

Feb 2nd, 2018
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Airplane1 {
  4.     public static void main(String[] agrs) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int hours = Integer.parseInt(scanner.nextLine());
  8.         int minutes = Integer.parseInt(scanner.nextLine());
  9.         int fly = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int TotalMinutes = hours * 60 + minutes;
  12.         int Arrive = fly + TotalMinutes;
  13.         int FlyMinutes = Arrive % 60;
  14.         int FlyHours = Arrive / 60;
  15.  
  16.         if (FlyHours >= 23) {
  17.             FlyHours = FlyHours - 24;
  18.  
  19.         }
  20.         if (FlyMinutes >= 60) {
  21.             FlyHours++;
  22.  
  23.         }
  24.         System.out.printf("%dh %dm", FlyHours, FlyMinutes);
  25.  
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement