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 ExamTimeHour = Integer.parseInt(scanner.nextLine());
- int ExamTimeMinute = Integer.parseInt(scanner.nextLine());
- int ArrivalHour = Integer.parseInt(scanner.nextLine());
- int ArrivalMinute = Integer.parseInt(scanner.nextLine());
- int timeExam = ExamTimeHour * 60 + ExamTimeMinute;
- int timeArrival = ArrivalHour * 60 + ArrivalMinute;
- if (timeArrival > timeExam) {
- int timeLate = timeArrival - timeExam;
- if (timeLate < 60) {
- System.out.println("Late");
- System.out.print(timeLate + " minutes after the start");
- } else if (timeLate >= 60) {
- int hoursLate = timeLate / 60;
- int minutesLate = timeLate % 60;
- System.out.println("Late");
- System.out.print(hoursLate + ":" + minutesLate + " hours after the start");
- }
- } else if ((timeArrival + 30 >= timeExam) && (timeArrival <= (timeExam + 30))) {
- int timeOnTime = timeExam - timeArrival;
- System.out.println("On time");
- System.out.print(timeOnTime + " minutes before the start");
- } else if (timeArrival < timeExam) {
- int timeEarly = timeExam - timeArrival;
- if (timeEarly < 60) {
- System.out.println("Early");
- System.out.print(timeEarly + " minutes before the start");
- } else if (timeEarly >= 60) {
- int hoursEarly = timeEarly / 60;
- int minutesEarly = timeEarly % 60;
- System.out.println("Early");
- System.out.print(hoursEarly + ":" + minutesEarly + " hours before the start");
- } else if (ExamTimeHour == ArrivalHour && ExamTimeMinute == ArrivalMinute) {
- System.out.println("On time");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement