Advertisement
desislava_topuzakova

02.Airplane - 07.01.2018

Mar 11th, 2018
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. package TestJan;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Airplane {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int hour = Integer.parseInt(scanner.nextLine());
  10.         int minutes = Integer.parseInt(scanner.nextLine());
  11.         int flightLasting = Integer.parseInt(scanner.nextLine());
  12.  
  13.         int lastingTimeHourandMinutes = hour * 60 + minutes + flightLasting;
  14.         int hourLasting = lastingTimeHourandMinutes / 60;
  15.         int minutesLasting = lastingTimeHourandMinutes % 60;
  16.  
  17.         if (minutesLasting >= 60) {
  18.             hour++;
  19.         }
  20.         if (hourLasting >= 23) {
  21.             hourLasting = hourLasting - 24;
  22.         }
  23.         System.out.println(hourLasting + "h " + minutesLasting + "m");
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement