Advertisement
desislava_topuzakova

Airplane 2

Feb 2nd, 2018
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class task2_Airplane {
  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.         int flightLasting = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int LastingTimeHourandMinutes = hour * 60 + minutes + flightLasting;
  12.         int hourLasting = LastingTimeHourandMinutes / 60;
  13.         int minutesLasting = LastingTimeHourandMinutes % 60;
  14.  
  15.         if (minutesLasting >= 60) {
  16.             hour++;
  17.         }
  18.         if (hourLasting >= 23) {
  19.             hourLasting = hourLasting - 24;
  20.         }
  21.         System.out.println(hourLasting + "h " + minutesLasting + "m");
  22.  
  23.  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement