Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int examHour = Integer.parseInt(scanner.nextLine());
- int examMinute = Integer.parseInt(scanner.nextLine());
- int arriveHour = Integer.parseInt(scanner.nextLine());
- int arriveMinute = Integer.parseInt(scanner.nextLine());
- int arriveTime = arriveHour * 60 + arriveMinute;
- int examTime = examHour * 60 + examMinute;
- int hours = 0;
- if (arriveTime > examTime) {
- int minutes = arriveTime - examTime;
- if (minutes >= 60) {
- hours = minutes / 60;
- minutes = minutes - 60 * hours;
- if (minutes < 10) {
- System.out.printf("Late%n%d:0%d hours after the start", hours, minutes);
- } else {
- System.out.printf("Late%n%d:%d hours after the start", hours, minutes);
- }
- } else {
- System.out.printf("Late%n%d minutes after the start", minutes);
- }
- } else if (examTime - arriveTime <= 30) {
- int minutes = examTime - arriveTime;
- System.out.printf("On time%n%d minutes before the start", minutes);
- } else {
- int minutes = examTime - arriveTime;
- if (minutes >= 60) {
- hours = minutes / 60;
- minutes = minutes - 60 * hours;
- if (minutes < 10) {
- System.out.printf("Early%n%d:0%d hours before the start", hours, minutes);
- } else {
- System.out.printf("Early%n%d:%d hours before the start", hours, minutes);
- }
- } else {
- System.out.printf("Early%n%d minutes before the start", minutes);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment