Advertisement
bobo_bobkata

Untitled

Nov 27th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package For;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class raw {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10.  
  11. int examHour = Integer.parseInt(scanner.nextLine());
  12. int examMinutes = Integer.parseInt(scanner.nextLine());
  13. int arriveHour = Integer.parseInt(scanner.nextLine());
  14. int arriveMinutes = Integer.parseInt(scanner.nextLine());
  15.  
  16. int totalExam = examHour * 60 + examMinutes;
  17. int totalArrive = arriveHour * 60 + arriveMinutes;
  18.  
  19. if(totalArrive > totalExam){
  20. System.out.println("Late");
  21. if(totalArrive - totalExam < 60){
  22. System.out.printf("%d minutes after the start", totalArrive - totalExam);
  23. }else{
  24. int lateHour = (totalArrive - totalExam) / 60;
  25. int lateMinute = (totalArrive - totalExam) % 60;
  26. System.out.printf("%d:%02d hours after the start",lateHour,lateMinute);
  27. }
  28.  
  29. }else if(totalArrive == totalExam || totalExam - totalArrive <= 30){
  30. System.out.println("On time");
  31. if(totalExam - totalArrive <= 30 && totalExam - totalArrive != 0){
  32. System.out.printf("%d minutes before the start",totalExam - totalArrive);
  33. }
  34.  
  35. }else if(totalExam - totalArrive > 30){
  36. System.out.println("Early");
  37. if(totalExam - totalArrive < 60){
  38. System.out.printf("%d minutes before the start", totalExam - totalArrive);
  39. }else {
  40. int earlyHour = (totalExam - totalArrive) / 60;
  41. int earlyMinute = (totalExam - totalArrive) % 60;
  42. System.out.printf("%d:%02d hours before the start",earlyHour,earlyMinute );
  43. }
  44. }
  45. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement