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 scanner = new Scanner(System.in);
- int examHour = Integer.parseInt(scanner.nextLine());
- int examMinute = Integer.parseInt(scanner.nextLine());
- int arrivalHour = Integer.parseInt(scanner.nextLine());
- int arrivalMinute = Integer.parseInt(scanner.nextLine());
- examMinute += examHour * 60;
- arrivalMinute += arrivalHour * 60;
- int difference = examMinute - arrivalMinute;
- if (difference < 0) {
- System.out.println("Late");
- if (Math.abs(difference) < 60) {
- System.out.printf("%d minutes after the start",Math.abs(difference));
- }else {
- System.out.printf("%d:%02d hours after the start",Math.abs(difference / 60),Math.abs(difference % 60));
- }
- }else if (difference > 0) {
- if (difference <= 30) {
- System.out.println("On time");
- }else {
- System.out.println("Early");
- }
- if (difference < 60) {
- System.out.printf("%d minutes before the start",difference);
- }else {
- System.out.printf("%d:%02d hours before the start",difference / 60,difference % 60);
- }
- }else {
- System.out.println("On time");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement