Advertisement
desislava_topuzakova

OnTheTimeForTheExam 1

Feb 2nd, 2018
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class OnTimeForTheExam {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8. int ExamTimeHour = Integer.parseInt(scanner.nextLine());
  9. int ExamTimeMinute = Integer.parseInt(scanner.nextLine());
  10. int ArrivalHour = Integer.parseInt(scanner.nextLine());
  11. int ArrivalMinute = Integer.parseInt(scanner.nextLine());
  12.  
  13. int timeExam = ExamTimeHour * 60 + ExamTimeMinute;
  14. int timeArrival = ArrivalHour * 60 + ArrivalMinute;
  15.  
  16. if (timeArrival > timeExam) {
  17. int timeLate = timeArrival - timeExam;
  18. if (timeLate < 60) {
  19. System.out.println("Late");
  20. System.out.print(timeLate + " minutes after the start");
  21. } else if (timeLate >= 60) {
  22. int hoursLate = timeLate / 60;
  23. int minutesLate = timeLate % 60;
  24. System.out.println("Late");
  25. System.out.print(hoursLate + ":" + minutesLate + " hours after the start");
  26. }
  27. } else if ((timeArrival + 30 >= timeExam) && (timeArrival <= (timeExam + 30))) {
  28. int timeOnTime = timeExam - timeArrival;
  29. System.out.println("On time");
  30. System.out.print(timeOnTime + " minutes before the start");
  31. } else if (timeArrival < timeExam) {
  32. int timeEarly = timeExam - timeArrival;
  33. if (timeEarly < 60) {
  34. System.out.println("Early");
  35. System.out.print(timeEarly + " minutes before the start");
  36. } else if (timeEarly >= 60) {
  37. int hoursEarly = timeEarly / 60;
  38. int minutesEarly = timeEarly % 60;
  39. System.out.println("Early");
  40. System.out.print(hoursEarly + ":" + minutesEarly + " hours before the start");
  41. } else if (ExamTimeHour == ArrivalHour && ExamTimeMinute == ArrivalMinute) {
  42. System.out.println("On time");
  43. }
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement