stoyanoff

OnTime-Zlatka

Jun 24th, 2020
1,484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Test {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int hourExam = Integer.parseInt(scanner.nextLine());
  7.         int minutesExam = Integer.parseInt(scanner.nextLine());
  8.         int hourArrive = Integer.parseInt(scanner.nextLine());
  9.         int minutesArrive = Integer.parseInt(scanner.nextLine());
  10.         int totalExamTime = hourExam * 60 + minutesExam;
  11.         int totalArriveTime = hourArrive * 60 + minutesArrive;
  12.         if (totalArriveTime > totalExamTime) {
  13.             System.out.println("Late");
  14.             int lateMinutes = totalArriveTime - totalExamTime;
  15.             if (lateMinutes < 60) {
  16.                 System.out.printf("%d minutes after the start", lateMinutes);
  17.             } else {
  18.                 int hour = lateMinutes / 60;
  19.                 int minutes = lateMinutes % 60;
  20.                 System.out.printf("%d:%02d hours after the start", hour, minutes);
  21.             }
  22.         } else if (totalArriveTime == totalExamTime || totalExamTime - totalArriveTime <= 30) { // промених < с <=
  23.             System.out.println("On time");
  24.             int ontime = totalExamTime - totalArriveTime;
  25.             if (ontime <= 30 && ontime != 0) {
  26.                 System.out.printf("%d minutes before the start", ontime);
  27.             }
  28.         } else if (totalExamTime - totalArriveTime > 30) {
  29.             System.out.println("Early");
  30.             int earlyMinutes = totalExamTime - totalArriveTime;
  31.             if (earlyMinutes < 60) {
  32.                 System.out.printf("%d minutes before the start", earlyMinutes);
  33.             } else {//earlyMinutes>=60
  34.                 int hours = earlyMinutes / 60;
  35.                 int minutes = earlyMinutes % 60;
  36.                 System.out.printf("%d:%02d hours before the start", hours, minutes); // имаше правописна грешка
  37.  
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment