aneliabogeva

On Time for Exam

Nov 11th, 2020
857
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class OnTimeForExam {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         Integer hourExam = Integer.parseInt(scanner.nextLine());
  7.         Integer minExam = Integer.parseInt(scanner.nextLine());
  8.         Integer hourArrive = Integer.parseInt(scanner.nextLine());
  9.         Integer minArrive = Integer.parseInt(scanner.nextLine());
  10.  
  11.         Integer totalMinExamTime = hourExam*60+minExam;
  12.         Integer totalMinArriveTime = hourArrive*60+minArrive;
  13.         Integer diffMinTime = Math.abs(totalMinExamTime-totalMinArriveTime);
  14.  
  15.         if(totalMinExamTime.equals(totalMinArriveTime)){
  16.             System.out.println("On time");
  17.         }else if(totalMinExamTime > totalMinArriveTime){
  18.             if(diffMinTime<=30){
  19.                 System.out.println("On time");
  20.                 System.out.printf("%d minutes before the start",diffMinTime);
  21.             }else {
  22.                 if(diffMinTime<60){
  23.                     System.out.println("Early");
  24.                     System.out.printf("%d minutes before the start",diffMinTime);
  25.                 }else{
  26.                     Integer timeForHour = (int)Math.floor(diffMinTime/60);
  27.                     Integer timeForMinutes = (diffMinTime%60);
  28.                     if(timeForMinutes < 10){
  29.                         System.out.println("Early");
  30.                         System.out.printf("%d:0%d hours before the start",timeForHour, timeForMinutes);
  31.                     }else{
  32.                         System.out.println("Early");
  33.                         System.out.printf("%d:%d hours before the start", timeForHour, timeForMinutes);
  34.                     }
  35.                 }
  36.             }
  37.         }else{
  38.             if(diffMinTime<=30){
  39.                 System.out.println("Late");
  40.                 System.out.printf("%d minutes after the start",diffMinTime);
  41.             }else {
  42.                 if(diffMinTime<60){
  43.                     System.out.println("Late");
  44.                     System.out.printf("%d minutes after the start",diffMinTime);
  45.                 }else{
  46.                     Integer timeForHour = (int)Math.floor(diffMinTime/60);
  47.                     Integer timeForMinutes = (diffMinTime%60);
  48.                     if(timeForMinutes < 10){
  49.                         System.out.println("Late");
  50.                         System.out.printf("%d:0%d hours after the start",timeForHour, timeForMinutes);
  51.                     }else{
  52.                         System.out.println("Late");
  53.                         System.out.printf("%d:%d hours after the start", timeForHour, timeForMinutes);
  54.                     }
  55.                 }
  56.             }
  57.         }
  58.     }
  59. }
  60.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×