Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OnTimeForTheExam
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- int examHours = Integer.parseInt(scan.nextLine());
- int examMinutes = Integer.parseInt(scan.nextLine());
- int arriveHours = Integer.parseInt(scan.nextLine());
- int arriveMinutes = Integer.parseInt(scan.nextLine());
- int diffTotalMinutes = (arriveHours * 60 + arriveMinutes) - (examHours * 60 + examMinutes);
- int diffHours = Math.abs(diffTotalMinutes / 60);
- int diffMinutes = Math.abs(diffTotalMinutes % 60);
- if (diffTotalMinutes > 0)
- {
- System.out.println("Late");
- }
- else if (diffTotalMinutes >= -30)
- {
- System.out.println("On time");
- }
- else {
- System.out.println("Early");
- }
- if (diffTotalMinutes >= 60)
- {
- System.out.printf("%d:%02d hours after the start", diffHours, diffMinutes);
- }
- else if (diffTotalMinutes > 0)
- {
- System.out.printf("%d minutes after the start", diffMinutes);
- }
- if (diffTotalMinutes <= -60)
- {
- System.out.printf("%d:%02d hours before the start", diffHours, diffMinutes);
- }
- else if (diffTotalMinutes < 0)
- {
- System.out.printf("%d minutes before the start", diffMinutes);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement