Advertisement
Gin10

Untitled

Feb 27th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class OnTimeForTheExam_09 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int examH = Integer.parseInt(scanner.nextLine());
  7. int examM = Integer.parseInt(scanner.nextLine());
  8. int comeH = Integer.parseInt(scanner.nextLine());
  9. int comeM = Integer.parseInt(scanner.nextLine());
  10. int examHToM = (examH * 60) + examM;
  11. int comeHToM = (comeH * 60) + comeM;
  12. int timeH = 0;
  13. int timeM = 0;
  14. if (examHToM > comeHToM && examHToM - 30 >= comeHToM){
  15. timeH = examHToM / comeHToM;
  16. timeM = examHToM % comeHToM;
  17. System.out.printf("On time %n%d minutes before the start", timeM);
  18. }else if (examHToM - 30 < comeHToM ){
  19. timeH = examHToM / comeHToM;
  20. timeM = examHToM % comeHToM;
  21. if (timeM == 60){
  22. timeM = 0;
  23. }
  24. System.out.printf("Early %n%d:%02d hours before the start", timeH, timeM);
  25. }else if (examHToM < comeHToM){
  26. timeH = comeHToM / examHToM;
  27. timeM = comeHToM % examHToM;
  28. if (timeH >= 1) {
  29. System.out.printf("Late %n%d:%0d hours after the start",timeH, timeM);
  30. }else if (timeH == 0 ){
  31. System.out.printf("Late %n%0d minutes after the start", timeM);
  32. }
  33. }else if (examHToM == comeHToM){
  34. System.out.printf("On time ");
  35. }
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement